String Compression II
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
Run-length encoding replaces each maximal run of the same character with the character followed by the run length. A run of length 1 is written as just the character (no 1), so "aabccc" becomes "a2bc3" (length 5), and a run of 12 as becomes "a12" (length 3).
Given a string s and an integer k, you may delete **at most** k characters from s (the rest keep their order). Return the minimum possible length of the run-length encoding of the resulting string.
The encoded length of a run of c equal characters is 1 if c == 1, 2 for 2..9, 3 for 10..99, and 4 for 100.
Examples
Constraints
- 1 <= s.length <= 100
- 0 <= k <= s.length
- s consists of lowercase English letters
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.