Final exam — Trees
Three unseen problems (not covered in the lessons) to test whether you leave this section able to solve any problem of the topic: one easy, one medium and one hard. Some test cases are hidden — like the real LeetCode. Solve in Python or JavaScript.
Symmetric Tree
Check whether a binary tree is mirrored around its center (the left subtree is the mirror of the right one).
Example: [1,2,2,3,4,4,3] → true. [1,2,2,null,3,null,3] → false.
Binary Tree Right Side View
Imagine yourself looking at the tree from the right side. Return the values of the nodes you can see, top to bottom (the rightmost node of each level).
Example: [1,2,3,null,5,null,4] → [1,3,4].
Binary Tree Maximum Path Sum
A path is any sequence of nodes connected by edges (it does not need to pass through the root nor reach a leaf; it turns at most one node). Return the largest sum of values along some path. Values may be negative.
Example: [-10,9,20,null,null,15,7] → 42 (the path 15 → 20 → 7). [1,2,3] → 6.