🚀 Phases 1–5 are live — Days 1–17 cover the foundations and the algorithmic patterns. See the roadmap →
Day 26 - Divide & ConquerPractice QuestionsOverview

D&C Practice Questions

Ten interview classics, every D&C shape represented. Each problem is a direct application of one of the four canonical recurrence forms or an advanced pattern — once you spot which shape it is, the code writes itself.

Before reading any solution, force yourself through the four-question checklist:

  1. How do I split the input?
  2. What’s the base case?
  3. What’s the combine step?
  4. What’s the recurrence and the runtime? (Use the Master Theorem.)

The code is a 10-line transcription of those four answers. If you can write the recurrence, you’ve already solved the analysis.

Easy

ProblemPatternStatus
Pow(x, n)Fast exponentiation, T(n) = T(n/2) + O(1)Available
Majority ElementT(n) = 2T(n/2) + O(n) plus Boyer-Moore alternativeAvailable

Medium

ProblemPatternStatus
Sort an Array (Merge Sort)Canonical T(n) = 2T(n/2) + O(n)Available
Kth Largest Element in an ArrayQuickselect, T(n) = T(n/2) + O(n) avgAvailable
Maximum Subarray (D&C)Left / right / crossing, T(n) = 2T(n/2) + O(n)Available
Different Ways to Add ParenthesesD&C on operator positions, exponential branchingAvailable
Search a 2D Matrix IIQuadrant-pruning D&C, staircase O(n+m) alternativeAvailable

Hard

ProblemPatternStatus
Count of Smaller Numbers After SelfMerge sort with extra accounting, O(n log n)Available
Median of Two Sorted ArraysBinary search on partition, O(log min(m, n))Available
The Skyline ProblemMerge-style D&C on building outlines, O(n log n)Available

More Practice (Coming Soon)

ProblemPatternStatus
Reverse PairsMerge sort with extra accountingComing Soon
Count of Range SumMerge sort on prefix sumsComing Soon
Largest Rectangle in Histogram (D&C)Recursive on minimum indexComing Soon
Closest Pair of PointsStrip-step D&CComing Soon
Burst BalloonsInterval D&C (also DP)Coming Soon
Find Peak ElementBinary-search D&CComing Soon
Convex Hull (Quickhull)D&C on point positionsComing Soon
K Closest Points to OriginQuickselect by distanceComing Soon
Construct BST from PreorderRecursive split on first elementComing Soon
Beautiful ArrayConstructive D&CComing Soon