A monitoring tool has several sorted lists of event timestamps, one per service. To show a single time window where every service did something, it needs the shortest range [lo, hi] that contains at least one timestamp from every list.
Write coveringRange(lists) that returns that range as [lo, hi]. A range [a, b] is better than [c, d] if b - a < d - c, or if the widths are equal and a < c. Every list is sorted ascending and non-empty.
Input: lists = [[1,10,20],[8,15],[12,30]] Output: [8,12]
10, 8, and 12 are all inside [8, 12], width 4. No narrower range covers all three lists.
Input: lists = [[5],[5],[5]] Output: [5,5]
All lists share 5, so the width is 0.
1 <= lists.length <= 10^51 <= lists[i].length <= 502 * 10^5 values.-10^5 <= value <= 10^5Run tries your code on the examples. Submit runs every test, including hidden edge cases and big inputs that check your code is fast enough, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #392 Smallest Window Covering Every Feed. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.