Advance or Jump to the Next Special Line
Problem statement
Start at line 1. next increments the current line by one. continue jumps to the first sorted nextLine value strictly greater than the current line.
Return the final line. Every continue command is guaranteed to have a destination.
Function
navigateLines(nextLine: int[], commands: String[]) → intExamples
Example 1
nextLine = [4,10]commands = ["next","continue","next"]return = 5The path is 1 to 2 to 4 to 5.
Example 2
nextLine = [4,10]commands = ["continue","next","next"]return = 6The path is 1 to 4 to 5 to 6.
Constraints
0 <= nextLine.length,commands.length <= 100000