Given a word, check whether the usage for capital letter is correct. The rules are: Capital letter should be the first one if there is only one.If there are more…
The tilt of a tree node is the absolute difference between the sum of all left subtree node values and all right subtree node values. If a node does not…
The diameter of a tree (sometimes called the width) is the number of nodes on the longest path between two end nodes. Given a binary tree, find out the diameter…
Given a binary search tree with positive values, find the minimum absolute difference between values of any two nodes. Sample Input: root =[18, 7, 25, 2, 13, None, 34, None, None, 10,…
In computer science, tree traversal (also known as tree search and walking the tree) is a form of graph traversal and refers to the process of visiting (checking and/or updating)…
A perfect binary tree is a binary tree in which all interior nodes have two children and all leaves have the same depth or same level. An example of a perfect binary tree is the (non-incestuous)…
A balanced binary tree, also referred to as a height-balanced binary tree, is defined as a binary tree in which the height of the left and right subtree of any…
Given two binary trees, merge them together using the following guidelines: For overlapping nodes, sum the weight together as the weight of the new node.For non-overlapping nodes, add the not…