Trains the technique from
LeetCode 785Is Graph Bipartite?This is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A repair depot has workstations numbered 0 through n - 1. Two workstations that draw
from the same power rail cannot be serviced during the same shift. The clash list is given
as conflicts, where conflicts[u] holds every workstation that clashes with workstation
u.
Clashes are mutual: whenever v occurs in conflicts[u], u occurs in conflicts[v].
No workstation clashes with itself, and no workstation is listed twice inside one entry.
Some workstations may have an empty clash list, and the clashes may break the floor into
several groups with no link between them.
The depot runs exactly two shifts, morning and evening, and every workstation must be
booked into one of them. Return true when a booking exists that keeps each clashing pair
in different shifts, and false when no such booking exists.
Example 1
Book workstations 0 and 1 in the morning and workstations 2, 3 and 4 in the evening. Each of the four listed clashes has its two ends in different shifts.
Example 2
Every way of booking these five workstations into two shifts leaves at least one listed clash with both ends in the same shift.
Example 3
No booking of all five workstations keeps every listed clash split across the two shifts.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def can_split_shifts(conflicts: list[list[int]]) -> bool:public boolean canSplitShifts(int[][] conflicts)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.