Next pattern in sweep
A soak test rig energizes relay lines in patterns. Bit i of a pattern is set when line i is energized, and slots gives how many lines the rig has, at most 30. A sweep visits every pattern that energizes exactly as many lines as the one it began with, taking them in ascending numeric order. The log names pattern as the last one that finished, and says skipped further patterns ran unrecorded before the rig died. Return the pattern the rig should restart from, the one sitting skipped places after pattern in that ascending order, or -1 when the order runs out first. A skipped of 0 asks for pattern itself. skipped can reach into the hundreds of millions, so stepping one pattern at a time will not finish.
resume_sweep_pattern(pattern: int, slots: int, skipped: int) → int[5,4,1]out6[3,3,2]out6[12,4,1]out-1State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
[5,4,1]6not run yetsample[3,3,2]6not run yetsample[12,4,1]-1not run yetsample