Advance or Jump to the Next Special Line
Updated
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
More ZipRecruiter Online Assessment questions
- Four-Level Banking System with Scheduled PaymentsOA · Seen Oct 2026
- Count Three-Digit Numbers with Distinct DigitsOA · Seen Oct 2024
- Longest Frequency-Bounded SubarrayOA · Seen Oct 2024
- Minimum Changes to Draw a YOA · Seen Oct 2024
- Apply Binary State OperationsOA · Seen Sep 2024
- Simulate Orchard Rot SpreadOA · Seen Sep 2024
- Compare Odd- and Even-Index SumsOA · Seen Sep 2024
- Coordinate Removals with Column GravityOA · Seen Sep 2024
- Lexicographically Smallest End ReversalOA · Seen Sep 2024
- Recursively Expanded Shell Command CountsOA · Seen Sep 2024
Similar questions at other companies
- Catch Fish with Reusable BaitsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
- Minimum Index Distance Between Person and CakeSnowflake · OA · PHONE SCREENSnowflake interview questions
- Meandering ArrayVerisk · OA
- Interleave Array HalvesAutodesk · OAAutodesk interview questions
- Collect Branches for a Bird NestVisa · OAVisa interview questions
- Maximum Requests in a Time WindowIBM · OAIBM interview questions
- Set IntersectionBlackRock · OABlackRock interview questions
- Can Every Package Fit in a BoxIMC Trading · OAIMC Trading interview questions
- Filter Odds and Reverse EvensUpstart · OAUpstart interview questions
- Score Difference When Even Picks Reverse the ListMicrosoft · OAMicrosoft interview questions