In-Place Run-Length Compression of a Character Array
Asked at Salesforce · Coding Questions · Difficulty: Medium · Last asked Apr 3, 2026
Given an array of characters, compress each run of identical consecutive characters in place. A run of length 1 is kept as the single character. A run of length `k >= 2` is replaced by the character followed by the decimal digits of `k`, one digit per array cell. After compressing, the first part of the array holds the compressed text, and the function returns that part's length.
Loading the problem…
More Salesforce interview questions
- Campaign Cost Weekly Partition
- Design a Collaborative Spreadsheet (Google Sheets)
- AI / ML Fundamentals Oral Round (AI Engineer)
- Rate Limiter for Expensive API with User-Configurable Monthly Quota
- Hiring Manager + Behavioral Rounds
- Design an Async Job / Task System