AO
Back

Run Length Encoding Problems

Phone ScreenPhone ScreenLast reported March 2026Low Frequency

Problem Overview

One first-hand report, from a Waymo phone screen: the candidate went on to the onsite. The original data B A A E E E C is run-length encoded as B1A2E3C1: each character followed by how many times it repeats. The reported functions are char Find(int p) and the follow-up char FindbyValue(char target, int left, int right), both working on the encoded data.

Here they are methods of a class built from the encoded string: RunLengthString(encoded). Indices are 0-based positions in the original data. Answer without decoding the string. The class and method names are our setup.

Part 1 — Character at an index

Write find(p: int) -> str: the character at index p of the original data. A count can have more than one digit (A12 is twelve As).

Part 2 — A bigger character in a sorted range

Reported follow-up: assume the original data is sorted. Write find_by_value(target: str, left: int, right: int) -> str | None: the report says "find the bigger char in range [left, right]". This page returns the smallest character in the inclusive index range [left, right] that is greater than target, and None when there is none. Ask what "the bigger char" means: the tests use ranges where it gives the same answer as "the largest character in the range, if it is bigger than target".

Follow-up Arc

Interviewers escalate through these phases. The order varies, but most candidates see at least one from each bucket.
Trade-off discussion · 1
Trade-off discussion

Implement char FindbyValue(char target, int left, int right): find the bigger char in the range [left, right] of the original data, assuming the input is sorted. (when: After Find(p))

Approach Trade-offs

Approaches actually attempted in reports — including ones that lost candidates time. Pick deliberately.
ApproachNotes
Linear scan of the runsWalk the runs adding up counts until the one containing p: O(m) per query instead of O(log m) with prefix sums and binary search.

Practice

Write your own against 8 test cases, or read the worked solution — approach, complexity, and code that runs.
Did this match your interview?

If you have had this round, tell us how close this page was. It is how we keep the pages accurate.

Waymo · Phone Screen · Reported 1× across candidate reports
Is this helpful?