Divide and Conquer LeetCode Problems: All 47, With Python Solutions
Every problem in this library that LeetCode tags Divide and Conquer — 47 in total, 41 of them with a complete Python solution, a worked example and the time and space complexity of the approach.
- 47 problems
- 5 Easy
- 26 Medium
- 16 Hard
Divide and Conquer problems by difficulty
Problems with a complete Python solution are listed first, then by ascending problem number.
Easy (5)
| # | Problem | Difficulty | Topics |
|---|---|---|---|
| 108 | Convert Sorted Array to Binary Search Tree | Easy | Tree, Binary Search Tree, Array +2 |
| 169 | Majority Element | Easy | Array, Hash Table, Divide and Conquer +2 |
| 190 | Reverse Bits | Easy | Bit Manipulation, Divide and Conquer |
| 191 | Number of 1 Bits | Easy | Bit Manipulation, Divide and Conquer |
| 1763 | Longest Nice Substring | Easy | Bit Manipulation, Hash Table, String +2 |
Medium (26)
| # | Problem | Difficulty | Topics |
|---|---|---|---|
| 53 | Maximum Subarray | Medium | Array, Divide and Conquer, Dynamic Programming |
| 105 | Construct Binary Tree from Preorder and Inorder Traversal | Medium | Tree, Array, Hash Table +2 |
| 106 | Construct Binary Tree from Inorder and Postorder Traversal | Medium | Tree, Array, Hash Table +2 |
| 109 | Convert Sorted List to Binary Search Tree | Medium | Tree, Binary Search Tree, Linked List +2 |
| 148 | Sort List | Medium | Linked List, Two Pointers, Divide and Conquer +2 |
| 215 | Kth Largest Element in an Array | Medium | Array, Divide and Conquer, Quickselect +2 |
| 240 | Search a 2D Matrix II | Medium | Array, Binary Search, Divide and Conquer +1 |
| 307 | Range Sum Query - Mutable | Medium | Design, Binary Indexed Tree, Segment Tree +2 |
| 324 | Wiggle Sort II | Medium | Greedy, Array, Divide and Conquer +2 |
| 347 | Top K Frequent Elements | Medium | Array, Hash Table, Divide and Conquer +5 |
| 372 | Super Pow | Medium | Math, Divide and Conquer |
| 395 | Longest Substring with At Least K Repeating Characters | Medium | Hash Table, String, Divide and Conquer +1 |
| 427 | Construct Quad Tree | Medium | Tree, Array, Divide and Conquer +1 |
| 558 | Logical OR of Two Binary Grids Represented as Quad-Trees | Medium | Tree, Divide and Conquer |
| 654 | Maximum Binary Tree | Medium | Stack, Tree, Array +3 |
| 889 | Construct Binary Tree from Preorder and Postorder Traversal | Medium | Tree, Array, Hash Table +2 |
| 912 | Sort an Array | Medium | Array, Divide and Conquer, Bucket Sort +5 |
| 918 | Maximum Sum Circular Subarray | Medium | Queue, Array, Divide and Conquer +2 |
| 932 | Beautiful Array | Medium | Array, Math, Divide and Conquer |
| 973 | K Closest Points to Origin | Medium | Geometry, Array, Math +4 |
| 1382 | Balance a Binary Search Tree | Medium | Greedy, Tree, Depth-First Search +3 |
| 1738 | Find Kth Largest XOR Coordinate Value | Medium | Bit Manipulation, Array, Divide and Conquer +5 |
| 1985 | Find the Kth Largest Integer in the Array | Medium | Array, String, Divide and Conquer +3 |
| 2343 | Query Kth Smallest Trimmed Number | Medium | Array, String, Divide and Conquer +4 |
| 1756 | Design Most Recently Used QueuePremium | Medium | Design, Array, Linked List +3 |
| 2031 | Count Subarrays With More Ones Than ZerosPremium | Medium | Binary Indexed Tree, Segment Tree, Array +5 |
Hard (16)
| # | Problem | Difficulty | Topics |
|---|---|---|---|
| 4 | Median of Two Sorted Arrays | Hard | Array, Binary Search, Divide and Conquer |
| 23 | Merge k Sorted Lists | Hard | Linked List, Divide and Conquer, Heap (Priority Queue) +1 |
| 218 | The Skyline Problem | Hard | Binary Indexed Tree, Segment Tree, Array +5 |
| 315 | Count of Smaller Numbers After Self | Hard | Binary Indexed Tree, Segment Tree, Array +4 |
| 327 | Count of Range Sum | Hard | Binary Indexed Tree, Segment Tree, Array +4 |
| 493 | Reverse Pairs | Hard | Binary Indexed Tree, Segment Tree, Array +4 |
| 1569 | Number of Ways to Reorder Array to Get Same BST | Hard | Tree, Union Find, Binary Search Tree +7 |
| 1649 | Create Sorted Array through Instructions | Hard | Binary Indexed Tree, Segment Tree, Array +4 |
| 1982 | Find Array Given Subset Sums | Hard | Array, Divide and Conquer |
| 2179 | Count Good Triplets in an Array | Hard | Binary Indexed Tree, Segment Tree, Array +4 |
| 2407 | Longest Increasing Subsequence II | Hard | Binary Indexed Tree, Segment Tree, Queue +4 |
| 2426 | Number of Pairs Satisfying Inequality | Hard | Binary Indexed Tree, Segment Tree, Array +4 |
| 1274 | Number of Ships in a RectanglePremium | Hard | Array, Divide and Conquer, Interactive |
| 2519 | Count the Number of K-Big IndicesPremium | Hard | Binary Indexed Tree, Segment Tree, Array +4 |
| 2613 | Beautiful PairsPremium | Hard | Geometry, Array, Math +3 |
| 2792 | Count Nodes That Are Great EnoughPremium | Hard | Tree, Depth-First Search, Divide and Conquer +1 |
Keep exploring
All LeetCode topicsEvery tag with a page of its own, with the number of problems behind each.LeetCode patternsThe techniques themselves, with a Python template and complexity for each.Curated study listsBlind 75, NeetCode 150 and three more, grouped by pattern.Easy problemsStart here when the data structure is new rather than the problem.
Other topics
- Array1,569
- String672
- Hash Table588
- Math485
- Dynamic Programming481
- Sorting392
- Greedy346
- Depth-First Search289
- Binary Search253
- Database249
- Tree225
- Breadth-First Search223
- Matrix216
- Two Pointers201
- Bit Manipulation194
- Binary Tree174
- Heap (Priority Queue)163
- Prefix Sum157
- Stack157
- Simulation144
- Graph138
- Counting126
- Design122
- Sliding Window116
When the Divide and Conquer problem arrives live
Stealth Interview is a desktop app for macOS and Windows. It reads the coding problem off your screen, returns a working solution with a step-by-step explanation and its time and space complexity, and transcribes what the interviewer is saying — while staying invisible to screen sharing.