Skip to main content

5.5 Exercises

Basic Difficulty

130. Surrounded Regions

Start by filling from the outer edges, then consider the inner regions.


257. Binary Tree Paths

Output all paths from the root to the leaves in a binary tree. What is the difference if backtracking is used?


Advanced Difficulty

47. Permutations II

A follow-up to the permutations problem. How to handle duplicate elements?


40. Combination Sum II

A follow-up to the combination problem. How to handle duplicate elements?


37. Sudoku Solver

A very classic Sudoku problem that can be solved using backtracking. In fact, there are many advanced search methods and pruning strategies, such as heuristic search, to improve speed for Sudoku-related problems.


310. Minimum Height Trees

How can this problem be transformed into a search problem? Should depth-first search or breadth-first search be used?