Recursion
Warm-up
- Find the height of a tree
- Hint: This is a potential recursion question because if you have the depth of both sub-trees, you can find the heigh of the tree
Practice
- Find all possible numbers that can be generated for a give sequence of numbers in a phone keypad
- Hint: This is a potential recursion question because of backtracking. Also if you try implementing it with loops, you will get stuck
- Use recursion to get to the last character of the string, building the word generated along the way and then backtrack
- Two players take turns adding, to a running total, any integer from 1..K. The player who first causes the running total to reach or exceed N wins.
- Hint: Draw the recursion tree!
Challenge (Optional)
Check out our upcoming interview prep bootcamp starting September 23/24 weekend