Basic Sorting Problems for Coding Interviews
40 basic Sorting problems from real coding interviews, each with test cases you can run online. By difficulty they split into 40 basic, 0 intermediate and 0 advanced. The companies that ask them most often are Google, Amazon, Microsoft, Bloomberg.
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
- Search Insert Position (Basic)
- Merge Two Sorted Arrays (Basic)
- Two Sum in a Sorted Array (Basic)
- Count Distinct Values (Basic)
- Sort Colors (Basic)
- Squares of a Sorted Array (Basic)
- Sort Array by Parity (Basic)
- Next Greatest Letter (Basic)
- Element Appearing Over a Quarter (Basic)
- Merge Two Sorted Arrays (Basic)
- Merge Multiple Sorted Sequences (Basic)
- Maximum Sum Path Across Two Arrays (Basic)
- Count Subarrays With Median K (Basic)
- Merge Two Sorted Lists (Basic)
- Sort a List of 0s 1s and 2s (Basic)
- Insert Into Sorted Linked List (Basic)
- Convert Sorted Array to BST (Basic)
- Count Sorted Vowel Strings (Basic)
- Custom Sort String (Basic)
- Sort Integers by Number of 1 Bits (Basic)
- Relative Sort Array (Basic)
- Sort Array by Parity II (Basic)
- Letter Case Permutation (Basic)
- Check if Array Is Sorted and Rotated (Basic)
- Maximum Ascending Subarray Sum (Basic)
- Sorted Union of Two Lists (Basic)
- Sorted Intersection of Two Lists (Basic)
- Sorting the Sentence (Basic)
- Sort Vowels in a String (Basic)
- Height Checker (Basic)
- Smaller Numbers Than Current (Basic)
- Fixed Point (Basic)
- Sort Array by Increasing Frequency (Basic)
- Single-Element Increments to Sort Array (Basic)
- Expected Inversions in Random Permutation (Basic)
- Distinct Absolute Values in Sorted Array (Basic)
- Bubble Sort Swap Count (Basic)
- Selection Sort Swap Count (Basic)
- Lower Median Score (Basic)
- Students Above the Class Median (Basic)
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.