Consider the following ranges as examples:
const ranges = [
[
0,
10,
],
[
20,
30,
],
[
40,
50,
],
];
In this scenario, I am looking to identify the missing ranges between two given values. For instance, if the input range was [-10, 60]
, the expected output should be as follows:
const islands = [
[
-10,
-1,
],
[
11,
19,
],
[
31,
39,
],
[
51,
60,
],
];
I attempted to search for terms like "disjoint ranges" and "non-intersecting ranges" but did not come across a solution. It seems like a common problem that may have been addressed numerous times in the past. Perhaps I am using incorrect search terms.