LeetCode- Implement Trie (Prefix Tree)
Implement a trie with insert, search, and startsWith methods. Example: Note: - You may assume that all inputs are consist of lowercase letters a-z. - All…
Implement a trie with insert, search, and startsWith methods. Example: Note: - You may assume that all inputs are consist of lowercase letters a-z. - All…
Given a binary tree, count the number of uni-value subtrees. A Uni-value subtree means all nodes of the subtree have the same value. Example : - 创建判断相同值子树方法…
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 inorder and postorder 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 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…