Better Compression

Problem Overview

  • Reformat a mis-compressed string S where letters are followed by counts; return a properly compressed string with one entry per letter, totals aggregated, in alphabetical order.
  • Input: S of length 1–100000 using 'a'–'z' with counts 1–1000; Output: corrected compressed string.
  • Domain: text parsing and data normalization for simple string compression.
  • Asked in Goldman interviews; a classic coding interview problem and interview question.

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: