Compressed Representation Size

Problem Overview

  • Compute the shortest possible length of a run-length compressed string after removing exactly K consecutive characters.
  • Input: string S (length N) and integer K; Output: minimal compressed length using counts for runs and leaving single letters as-is.
  • Domain: string compression (RLE) with a preprocessing step to delete a contiguous segment.
  • This Microsoft interviews problem is a classic coding interview 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: