Find the Overlapping Range

Published by Mubashir Hassan in

For an array of ranges, find the maximum range that is contained in all the ranges. If there is no such range, return [].

Examples

overlapping([[1, 7], [2, 8], [0, 4]]) ➞ [2, 4]

overlapping([[5, 10], [2, 15], [10, 12]]) ➞ [10, 10]

overlapping([[11, 18], [3, 7], [2, 20], [5, 16]]) ➞ []

Notes

Both ends are inclusive for all ranges.

Watch a quick demo on how Edabit works.