Loading...

The Character Encoder

A easy Python interview practice problem on DataDriven. Write and execute real python code with instant grading.

Domain
Python
Difficulty
easy
Seniority
junior, mid

Problem

The compression team is benchmarking a simple encoding scheme on raw text and needs a quick prototype to test against their C++ implementation. Given a string, compress it so that consecutive runs of the same character are replaced by the character followed by the run length.

Practice This Problem

Solve this Python problem with real code execution. DataDriven runs your Python code in a sandboxed Docker environment and grades it instantly.