leetcode

341. Flatten Nested List Iterator

Stack solution code

constructor

Time complexity: O(n)

Space complexity: O(n)

next

Time complexity: O(1)

Space complexity: O(n)

hasNext

Time complexity: O(1)

Space complexity: O(n)

Lazy solution code

constructor

Time complexity: O(1)

Space complexity: O(n)

next

Time complexity: O(n)

Space complexity: O(n)

hasNext

Time complexity: O(n)

Space complexity: O(n)