Sweep Line Problems for Coding Interviews
18 Sweep Line problems from real coding interviews, each with test cases you can run online. By difficulty they split into 3 basic, 11 intermediate and 4 advanced. The companies that ask them most often are Amazon, Google, Meta, Microsoft.
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
- Merge Intervals (Intermediate)
- Insert an Interval (Intermediate)
- Minimum Platforms for Events (Basic)
- Skyline Key Points (Basic)
- Minimum Platforms With Cleanup Time (Intermediate)
- Maximum Non-Overlapping Target Segments (Advanced)
- Common Free Time (Intermediate)
- Three Non-Overlapping Subarrays (Advanced)
- Extra Characters in a String (Intermediate)
- Car Pooling (Intermediate)
- Meeting Rooms (Basic)
- Max Increase to Keep City Skyline (Intermediate)
- Two Best Non-Overlapping Events (Intermediate)
- Sets of K Non-Overlapping Line Segments (Advanced)
- Two Non-Overlapping Subarrays With Target Sum (Intermediate)
- Meeting Rooms III (Advanced)
- Longest Non-Overlapping Border (Intermediate)
- Maximum Sum of Two Non-Overlapping Subarrays (Intermediate)
Related
Frequently asked questions
How do I get good at sweep line 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 sweep line 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.