1. Implement Trie (Prefix Tree)historical

    Implement a Trie (prefix tree) with the three operations insert, search, and startsWith.

  2. Unique Binary Search Treeshistorical

    Given an integer n, determine how many binary search trees can be formed using nodes 1 ... n.

  3. Binary Tree Inorder Traversalhistorical

    Given the root root of a binary tree, return its inorder traversal.

  4. Construct Binary Tree from Preorder and Inorder Traversalhistorical

    Construct a binary tree from its preorder traversal and inorder traversal.

  5. Binary Tree Preorder, Inorder, and Postorder Traversalhistorical

    Print all nodes of a binary tree in preorder, inorder, and postorder respectively.

  6. Convert BST to Greater Treehistorical

    Given the root of a binary search tree whose node values are distinct, convert it to a Greater Sum Tree so that the new value of each node equals the sum of all values in the original tree that are greater than or equal to node.val.

  7. Validate Binary Search Treehistorical

    Given a binary tree, determine whether it is a valid binary search tree.

  8. Flatten Binary Tree to Linked Listhistorical

    Flatten a binary tree in place into a linked list whose node order follows the tree's preorder traversal.

  9. Lowest Common Ancestor of a Binary Treehistorical

    Given a binary tree, find the lowest common ancestor of two specified nodes in the tree.

  10. Diameter of Binary Treehistorical

    Given a binary tree, calculate its diameter. The diameter of a binary tree is the maximum path length between any two nodes. This path may or may not pass through the root.

  11. Lowest Common Ancestor Nodehistorical

    Given a binary tree and two nodes o1 and o2 in the tree, find their lowest common ancestor.

  12. Merge Two Binary Treeshistorical

    Merge two binary trees by adding the values of overlapping nodes and retaining nodes that do not overlap.

  13. Symmetric Treehistorical

    Given a binary tree, check whether it is mirror-symmetric.

  14. House Robber IIIhistorical

    Houses form a binary tree, and a parent and its child cannot both be robbed. Choose houses that maximize the total amount stolen.

  15. Sum Root to Leaf Numbershistorical

    Each binary-tree node contains a digit from 0 to 9. Root-to-leaf paths form integers; return their total sum.

  16. Invert Binary Treehistorical

    Invert a binary tree.

  17. Path Sum IIIhistorical

    Count downward paths in an integer-valued binary tree whose sum equals a target. Paths need not start at the root or end at a leaf.

  18. Maximum Depth of Binary Treehistorical

    Given a binary tree, find its maximum depth.

  19. Binary Tree Maximum Path Sumhistorical

    A path in a binary tree may connect any nodes through parent-child edges. Find the nonempty path with the largest sum of node values.

  20. Binary Tree Right Side Viewhistorical

    Given a binary tree, imagine standing on its right side. Return the values of the nodes visible from the right, ordered from top to bottom.

  21. Binary Tree Level Order Traversalhistorical

    Given a binary tree, return the node values obtained by level-order traversal (that is, visit all nodes level by level from left to right).

  22. Serialize and Deserialize Binary Treehistorical

    Serialization converts a data structure or object into a continuous representation so the result can be stored in a file or memory, transmitted over a network, and later reconstructed by the reverse operation.

  23. Binary Tree Zigzag Level Order Traversalhistorical

    Given the root root of a binary tree, return the zigzag level-order traversal of its node values (left to right on one level, then right to left on the next, alternating between levels).