Design an Iterator class, which has:
characters
of sorted
distinct lowercase English letters and a number combinationLength
as arguments.
combinationLength
in lexicographical order.
True
if and only if there
exists a next combination.
Example:
CombinationIterator iterator = new CombinationIterator("abc", 2); // creates the iterator. iterator.next(); // returns "ab" iterator.hasNext(); // returns true iterator.next(); // returns "ac" iterator.hasNext(); // returns true iterator.next(); // returns "bc" iterator.hasNext(); // returns false
Constraints:
1 <= combinationLength <= characters.length <= 15
10^4
function calls per test.next
are
valid.