Run-Length Decoded String Iterator
Given a run-length encoded lowercase alphabet string s
, implement an iterator which is the decoded version of s
:
next()
polls the next element in the iteratorhasnext()
which returns whether the next element exists
Constraints
n ≤ 100,000
wheren
is the number of calls tonext
andhasnext
https://binarysearch.com/problems/Run-Length-Decoded-String-Iterator
Examples
Example 1
Input
- methods =
['constructor', 'next', 'hasnext', 'next', 'next', 'hasnext']
- arguments =
[['2a1b'], [], [], [], [], []]
Output
- answer =
[None, 'a', True, 'a', 'b', False]
Leave a comment