Shortest Compressed String After Removal

Problem Overview

  • Determine the shortest possible length of the run-length compressed string after removing exactly K consecutive characters from S.
  • Input: uppercase string S (length N) and integer K (0 ≤ K ≤ N); output: minimal compressed length.
  • Compression rule: each run becomes count+char; single letters stay unchanged.
  • Domain: string processing and compression for storage efficiency.
  • From Microsoft interviews: a coding interview problem and common 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: