Final exam — Intervals
Three unseen problems (not covered in the lessons) to test whether you leave this section able to solve any problem of the topic: one easy, one medium and one hard. Some test cases are hidden — like the real LeetCode. Solve in Python or JavaScript.
Summary Ranges
Given a sorted array nums of unique integers, return the list of ranges that cover exactly the numbers, as strings. A lone number becomes "a"; a consecutive run becomes "a->b".
Example: [0,1,2,4,5,7] → ["0->2","4->5","7"].
Interval List Intersections
Given two lists of intervals A and B, each sorted and internally non-overlapping, return the list of intersections between them (also sorted).
Example: A = [[0,2],[5,10],[13,23],[24,25]], B = [[1,5],[8,12],[15,24],[25,26]] → [[1,2],[5,5],[8,10],[15,23],[24,24],[25,25]].
Car Pooling
A car with capacity seats drives a one-way route. Each trip is [passengers, from, to] (they board at from, get off at to). Return true if it's possible to make all the trips without ever exceeding the capacity.
Example: trips = [[2,1,5],[3,3,7]], capacity = 4 → false (in [3,5] there are 5 passengers); with capacity = 5 → true.