Museum Corridor Sweep
You can think of this as a small game with a very specific goal. In Museum Corridor Sweep, you are trying to work toward the right number by following one clear idea.
This problem hides a best streak, chain, or longest piece inside a larger list. You are not always taking everything. Instead, you are searching for the strongest run that still follows the rule. A choice that looks good right now may not always lead to the best final result, so careful thinking matters.
For example, if the input is n = 6, corridors = [[0,1],[1,2],[0,2],[3,4]], start = 1, the answer is 3. Rooms 0, 1, and 2 form one connected section; rooms 3 and 4 are separate. Another example is n = 4, corridors = [[0,1],[2,3]], start = 2, which gives 2. The sweep reaches rooms 2 and 3; the other rooms remain unchecked.
This is a friendly practice problem, but it still rewards careful reading. The key is to look for the best hidden streak, not just the first one that seems okay.
Example Input & Output
Rooms 0, 1, and 2 form one connected section; rooms 3 and 4 are separate.
The sweep reaches rooms 2 and 3; the other rooms remain unchecked.
The sweep moves through every room in sequence without revisiting any room.
Algorithm Flow

Best Answers
import java.util.*;
class Solution {
public int calculate_min_workers(int[][] workers, int length) {
Arrays.sort(workers, (a, b) -> a[0] - b[0]);
int res = 0, currentFar = 0, i = 0;
while (currentFar < length) {
int nextFar = currentFar;
while (i < workers.length && workers[i][0] <= currentFar) {
nextFar = Math.max(nextFar, workers[i][1]);
i++;
}
if (nextFar == currentFar) return -1;
res++;
currentFar = nextFar;
}
return res;
}
}Comments (0)
Join the Discussion
Share your thoughts, ask questions, or help others with this Challenge.
