Question bank › Strings
Dsa Strings Medium

RLE Stream Difference

Two strings are provided in a Run-Length Encoded (RLE) format: 'count[char]count[char]...'. The counts can be extremely large (up to 10^12), so you cannot decompress the strings. Find the first index (0-based) in the decompressed strings where the characters differ. If the strings are identical, print -1. If one string is a prefix of the other, print the length of the shorter string. Example: Input: 3[A]2[B] 2[A]3[B] Decompressed: 'AAABB' vs 'AABBB'. First difference at index 2. Output: 2

Key concepts

run-length encodinggeneratorsstreaming

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.