LeetCode 900. RLE Iterator
Implement an iterator over a run-length encoded sequence represented as an array of (count, value) pairs. Support a next(n) operation that exhausts the next n elements by advancing through the encoded pairs and returns the last element exhausted, or -1 if there are no more elements. The solution must maintain state across calls and efficiently handle large values of n by skipping/consuming counts without decoding the full sequence.
Asked at:
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
All Regions
Early March, 2026
Junior
Hello Interview Premium
Your account is free and you can post anonymously if you choose.