Divide and conquer [mp]
Micro pattern¶
Description¶
Split a problem into smaller pieces, solve them independently, and combine their results.
Problems¶
Trees¶
Choose a root and construct or count independent left and right subtrees.
- 108. Convert Sorted Array to Binary Search Tree (Top Easy)
- 105. Construct Binary Tree from Preorder and Inorder Traversal (Top Medium)
- 96. Unique Binary Search Trees (Dynamic Programming)
- 95. Unique Binary Search Trees II (Dynamic Programming)
Sorting¶
Split or partition ranges and sort their independent parts.
- Top-down merge sort (DSA)
- Top-down merge sort linked list (DSA)
- Quick sort (DSA)
Interval optimization¶
Choose a final operation separating an interval into independent subproblems.
- 312. Burst Balloons (Top Hard)