Problem · Array
Debugger Breakpoint Actions
Learn this problemProblem statement
A debugger starts on line 1 of a code snippet whose final line is codeLength. The sorted array breakpoints contains the unique line numbers that have breakpoints.
Process the strings in actions in order:
"next"moves the debugger forward by exactly one line."continue"moves the debugger to the first breakpoint strictly after its current line.
Every action is valid: "next" is never used on the final line, and a later breakpoint always exists for "continue".
Return the line on which the debugger stops after every action has been processed.
Function
debuggerFinalLine(codeLength: int, breakpoints: int[], actions: String[]) → intExamples
Example 1
codeLength = 55breakpoints = [2,5,21,44]actions = ["next","next","continue","next","next"]return = 7The two "next" actions move from line 1 to line 3. The next breakpoint after line 3 is line 5, and the final two actions move to line 7.
Example 2
codeLength = 10breakpoints = [4,8]actions = ["continue","next","continue"]return = 8The debugger continues to line 4, advances to line 5, and then continues to line 8.
Example 3
codeLength = 6breakpoints = [2,4,6]actions = ["next","continue","next"]return = 5The debugger moves to line 2, continues to the next breakpoint on line 4, and advances once to line 5.
Constraints
codeLength >= 1breakpointsis sorted in strictly increasing order.1 <= breakpoints[i] <= codeLength- Every action is either
"next"or"continue". - A
"next"action is never performed on linecodeLength. - For every
"continue"action, a breakpoint exists strictly after the current line.
More Tiktok problems
- Concatenate Digit-wise SumsOA · Seen Aug 2026
- Count 2x2 Submatrices by Black CellsOA · Seen Aug 2026
- Count House Segments After DestructionOA · Seen Aug 2026
- Distribution Center Package AllocationOA · Seen Aug 2026
- Find All Local PeaksOA · Seen Aug 2026
- Minimum Height Difference Between Distant PeaksOA · Seen Aug 2026
- Minimum Operations for Stepwise StructuresOA · Seen Aug 2026
- Rating Level After ChangesOA · Seen Aug 2026