Hopper's fare search can produce two availability ranges for the same flight. Given two inclusive integer ranges, determine their overlap or return both ranges in ascending order when they are disjoint.
Implement resolve_ranges(range1, range2), where each input is a two-element list [start, end] with start <= end.
[max(start1, start2), min(end1, end2)].[[earlier_start, earlier_end], [later_start, later_end]].Example 1
Input: range1 = [1, 3], range2 = [2, 7]
Output: [2, 3]
The common inclusive portion is from 2 through 3.
Example 2
Input: range1 = [8, 10], range2 = [2, 5]
Output: [[2, 5], [8, 10]]
The ranges are disjoint, so they are returned in ascending order.
Example 3
Input: range1 = [4, 6], range2 = [6, 9]
Output: [6, 6]
The ranges overlap at their shared endpoint.
def resolve_ranges(range1, range2):