Practice/Google/Leetcode 3262. Find Overlapping Shifts
CodingMust
You are developing a scheduling system for a company that needs to detect conflicts in employee work schedules. Given a list of work shifts where each shift is represented as an interval [start, end] indicating the start and end times, return all pairs of shift indices that have overlapping time periods.
Two shifts overlap if they share any common time. Note that if one shift ends exactly when another begins (e.g., [1, 5] and [5, 10]), they are considered adjacent but not overlapping.
Return the result as a list of pairs [i, j] where i < j and shifts i and j overlap. The pairs should be sorted in ascending order.
[i, j] where i < j0 <= shifts.length <= 1000shifts[i].length == 20 <= start_i < end_i <= 10^6Example 1:
Input: shifts = [[1, 4], [2, 6], [8, 10]] Output: [[0, 1]] Explanation: Shift 0 (1-4) and Shift 1 (2-6) overlap during the time period [2, 4). Shift 2 (8-10) doesn't overlap with any other shift.
Example 2:
` Input: shifts = [[1, 3], [2, 5], [4, 7], [6, 8]] Output: [[0, 1], [1, 2], [2, 3]] Explanation:
Example 3:
Input: shifts = [[1, 5], [5, 10]] Output: [] Explanation: These shifts are adjacent but not overlapping since one ends exactly when the other begins.