Back to problems

Run-Length Encoding (RLE)

Algorithm · Databricks · Medium

Implement run-length encoding (RLE) and decoding for strings made of standard ASCII characters. A run is a maximal consecutive block of identical characters. The compressed form represents each run as a decimal count followed by that character, so four consecutive 'A' characters become "4A", and a single 'B' becomes "1B". Create two routines: compress(String original): returns the RLE-encoded string. decompress(String encoded): returns the original string described by a…

Checking your access…