Loading...

The Squeeze

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

Domain
Python
Difficulty
easy
Seniority
junior

Problem

Our message queue applies lightweight compression before transmission. Write a function that compresses a string using run-length encoding - 'aabcccaaa' becomes 'a2b1c3a3'. If the compressed version isn't shorter, return the original string unmodified.

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.