Quick coding interview advice for making your implementation go more smoothly:
Write the main logic first, using yet-to-be-written helper methods for smaller, self-contained bits of code that get in the way of the main algorithm. The main logic is what the interviewer wants to see the most, and, until you finish it, there is always a chance you may need to change course and use different helper functions.
For example, functions about intervals often require us to work out interval logic, like:
- Do two intervals overlap?
- What is the intersection of two intervals?
- Is an interval contained in another?
Don't get bogged down on those details early on. Those are great candidates for helper functions.