Logo

Coding preview

Run-Length Encoding and Decoding II

What this preview is

About this preview

Run-Length Encoding and Decoding II is a medium quant coding problem on language knowledge in Python.

Unlock full access to getcracked

Join to unlock this problem, detailed solutions, and our complete library of quant finance interview prep.

Parsing and comparing compressed-string representations in Python

This medium-difficulty coding problem tests your ability to parse a custom string format with nested structure, extract semantic content, and compare two superficially different inputs for logical equivalence. It is representative of problems that probe careful parsing and data-structure design.

The core challenge is building a parser that correctly handles multi-digit counts, parenthetical grouping with multipliers, and nesting. Once you can reliably extract the character frequencies from each compressed string, comparison becomes straightforward. Strong solutions parse cleanly (often using a stack or recursive descent), avoid off-by-one errors in count accumulation, and handle edge cases like implicit counts and nested bracket multipliers without duplication or loss.

  • Recursive descent parsing and stack-based evaluation
  • Extracting and accumulating character frequencies from structured input
  • Handling implicit counts and multiplicative effects of nested groups
  • Dictionary or counter-based comparison for equivalence