Space is cheap. Time, isn't
As the say goes: " Space is cheap. Time, isn't ". In today's world it is almost always the case that you can spare an extra few bytes here and there, but rest assure that your customer won't spare few extra milliseconds to wait for your site to load. Always err on the side of optimizing for speed. Mem is cheap. Here is the problem (LC, medium): https://leetcode.com/problems/iterator-for-combination/ 1286. Iterator for Combination Medium 485 41 Add to List Share Design an Iterator class, which has: A constructor that takes a string characters of sorted distinct lowercase English letters and a number combinationLength as arguments. A function next() that returns the next combination of length combinationLength in lexicographical order . A function hasNext() that returns True if and only if there exists a next combination. Example: CombinationIterator iterator = new Combin...