Advanced Sorting Problems for Coding Interviews
25 advanced Sorting problems from real coding interviews, each with test cases you can run online. By difficulty they split into 0 basic, 0 intermediate and 25 advanced. The companies that ask them most often are Amazon, Google, Bloomberg, Meta.
Solve a few problems of each level, name the pattern after each one and revisit the ones that needed a hint a week later. Practise stating the time and space complexity and the edge cases before you code.
Coding problems
- Count Inversions (Advanced)
- Search in a Rotated Sorted Array (Advanced)
- Max Chunks to Make Sorted (Advanced)
- Tree Nodes at Distance K (Advanced)
- Smallest Range Across K Lists (Advanced)
- Count Negative Values in Sorted Matrix (Advanced)
- Time Series Gap Detection (Advanced)
- Bridges in a Graph (Advanced)
- Alien Dictionary Order (Advanced)
- Shortest Subarray to Remove to Make Sorted (Advanced)
- Median of Two Sorted Arrays (Advanced)
- Kth Smallest Prime Fraction (Advanced)
- Word Break II (Advanced)
- Expression Add Operators (Advanced)
- Suffix Array Construction (Advanced)
- Burrows-Wheeler Transform (Advanced)
- Reverse Pairs (Advanced)
- Kth Shortest Path Length (Advanced)
- Delete Columns to Make Sorted III (Advanced)
- Grid Paths Avoiding Blocked Cells (Advanced)
- Kth Smallest in Two Sorted Arrays (Advanced)
- Edges From Prufer Sequence (Advanced)
- Expected Inversions of Independent Uniform Variables (Advanced)
- Minimum Cost to Sort Distinct Array by Swaps (Advanced)
- Stooge Sort Comparison Count (Advanced)
Related
Frequently asked questions
How do I get good at sorting problems?
Practise by level, name the pattern after you solve each problem and review the ones you needed hints for. The list is ordered so you can start with the basic ones.
Can I run sorting problems online here?
Yes. Each problem opens in an editor that runs your code against test cases in Java, Python, C++, Go, JavaScript and more.