String Compression Problem

String Compression Problem — ExecCode Medium DSA Practice

Solve the String Compression problem on ExecCode. Free online medium DSA practice in Arrays - Basics. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Compress the array of characters in-place using run-length counts. Return the new length. For String Compression, focus on the exact input variables, return only the requested value, and preserve the required time complexity for the intended pattern.

Examples

Input chars = ["a", "a", "b", "b", "c", "c", "c"]; Output 6

Constraints

1 ≤ n ≤ 10^5 Values fit interview constraints

Practice String Compression free on ExecCode. Browse DSA problems, topic map, and placement guides.