Recursively Sum Identical Digit Runs
Updated
Problem statement
Given a decimal digit string, replace every maximal repeated-digit run by the decimal representation of digit × run length. Single-character runs remain that digit.
Repeat whole passes when a replacement creates adjacent equal digits, stopping when all adjacent digits differ. Return the final string.
Function
compressDigitRuns(digits: String) → StringExamples
Example 1
digits = "66644319333"return = "26328"Repeated passes collapse the newly adjacent digits until no equal neighbors remain.
Example 2
digits = "123"return = "123"No run needs replacement.
Constraints
1 <= digits.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
- Reliable LLM Call with Independent Retry BudgetsStripe · OAStripe interview questions
- Tennis Game ScoreAbridge · OAAbridge interview questions
- Compress Editor Actions into Operational Transform OperationsReplit · OA · PHONE SCREEN · ONSITE INTERVIEW
- Robot Assembly Line ConflictsGoogle · OAGoogle interview questions
- Parcel Event TrackingAirbnb · OAAirbnb interview questions
- Repair One Movement InstructionOpenAI · OAOpenAI interview questions
- Count Straight-Line Word Occurrences in a GridOptiver · OAOptiver interview questions
- Format TextTikTok · OATikTok interview questions
- Binary String Swap TimeMicrosoft · OAMicrosoft interview questions
- Communications HandlerAkuna Capital · OAAkuna Capital interview questions