ranges, where ranges[i] = [lo, hi] stands for every integer from lo to hi inclusive. The length of a range is how many integers it holds, hi - lo + 1.
You are also given a list of points points. For each point, find the shortest range that contains it and record its length. If no range contains the point, record -1.
Return the answers in the order of the points.ranges=[[3, 9], [5, 6], [8, 8], [1, 4]], points=[5, 8, 2, 12] → [2, 1, 4, -1]
Point 5 lies in [3, 9] and [5, 6]; the latter is narrower, length 2. Point 8 is covered by [8, 8] of length 1. Point 2 only by [1, 4], length 4. Nothing covers 12.
ranges=[[10, 20]], points=[20, 21, 10] → [11, -1, 11]
Ends are included, so 20 and 10 are covered (length 11), but 21 is not.
ranges=[[3, 9], [5, 6], [8, 8], [1, 4]], points=[5, 8, 2, 12]
[2, 1, 4, -1]
Run checks the first 3 tests in your browser. Submit checks all 105 tests on the server, hidden ones included.