Smallest Resource Availability Window
In the aftermath of a large-scale natural disaster, multiple emergency response teams are deployed across different regions to provide critical aid. Each team maintains a log of timestamps indicating when essential resources—such as food, water, and medical supplies—are made available in their assigned areas. These timestamps are recorded in non-decreasing order, reflecting the real-time flow of aid to each region.
To ensure efficient coordination among the response teams, it becomes crucial to identify the smallest possible time range during which at least one resource is available from each team. Such a window allows for synchronized planning and effective mobilization of resources across all affected zones.
A time range [a,b] is considered smaller than another range [c,d] if the duration b−a is less than d−c, or if both durations are equal but a<c. Finding this minimal overlapping window is key to maximizing the impact of coordinated relief efforts.
Input format :
The input contains a list of k integer lists, where each sublist is enclosed in square brackets and contains comma-separated integers in non-decreasing order, with the entire structure wrapped in an outer list.
Output format :
The output prints a pair of space-separated integers enclosed in square brackets, representing the smallest inclusive range a,b that includes at least one number from each of the k lists.
Refer to the sample output for formatting specifications.
Code constraints :
1 ≤ k ≤ 3500 - where k is the number of lists.
1 ≤ nums[i].length ≤ 50 - each list contains at least 1 and at most 50 integers.
-10⁵ ≤ nums[i][j] ≤ 10⁵ - integers in the lists can range from -100,000 to 100,000.
All lists are sorted in non-decreasing order.
Sample test cases :
Input 1 :
[[4,10,15,24,26],[0,9,12,20],[5,18,22,30]]
Output 1 :
[20,24]
Input 2 :
[[1,2,3],[1,2,3],[1,2,3]]
Output 2 :
[1,1]
Java code without comments