LeetCode- Replace Words Solution
In English, we have a concept called root, which can be followed by some other word to form another longer word - let's call this word successor. For example…
In English, we have a concept called root, which can be followed by some other word to form another longer word - let's call this word successor. For example…
LeetCode- Map Sum Pairs Solution - Implement a MapSum class with insert, and sum methods
Given preorder and inorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do not exist in the tree. For example, given…
Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According to the definition of LCA on Wikipedia: “The lowest common…
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. Note: A…
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree [1,2,2,3,4,4,3] is symmetric: But…
Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.…
Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.…
Given a binary tree, return the _level order_ traversal of its nodes' values. (ie, from left to right, level by level). For example: Given binary tree [3,9,20…
Given a binary tree, return the _postorder_ traversal of its nodes' values. Example: Input: [1,null,2,3] \\ / Output: [3,2,1] Follow up: Recursive solution…