i stands at the point trees[i] = [x, y]. The rangers want to cut a vertical firebreak: a strip between two vertical lines, endless upward and downward, with no tree strictly inside it. Trees standing exactly on the edge of the strip are fine.
Each edge of the firebreak must pass through some tree. Return the greatest possible width of such a strip.trees=[[6, 2], [1, 5], [9, 9], [3, 0]] → 3
The x coordinates in order are 1, 3, 6, 9. The widest gap lies between 3 and 6, and its width is 3.
trees=[[4, 1], [4, 8], [5, 3]] → 1
Two trees share the vertical line x = 4, so there is no strip between them. That leaves the gap from 4 to 5, of width 1.
trees=[[0, 0], [10, 10], [2, 7], [8, 1]] → 6
trees=[[6, 2], [1, 5], [9, 9], [3, 0]]
3
Run checks the first 3 tests in your browser. Submit checks all 104 tests on the server, hidden ones included.