先序遍历
Data Structures & Algorithms · 10 notes
- 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.
- Lowest Common Ancestor of a Binary Treehistorical
Given a binary tree, find the lowest common ancestor of two specified nodes in the tree.
- 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.
- Lowest Common Ancestor Nodehistorical
Given a binary tree and two nodes o1 and o2 in the tree, find their lowest common ancestor.
- Merge Two Binary Treeshistorical
Merge two binary trees by adding the values of overlapping nodes and retaining nodes that do not overlap.
- 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.
- 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.
- 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.