Dot Product of Two Run-Length Encoded Vectors

Asked at Google · Coding Questions · Difficulty: Medium · Last asked Jan 21, 2026

A very long integer vector with many repeated neighbours is stored in run-length form: a list of `(value, run_length)` pairs, where each pair stands for `run_length` consecutive copies of `value`. Compute the dot product of two such vectors without expanding them.

Loading the problem…