173. Binary Search Tree Iterator (stack)

time: O(n), n is node nums, to constuct iterator

space: O(n), use stack, there are n nodes number add to stack

next(): O(1), average, somtimes need add left nodes

hasNext(): O(1),

Last updated

Was this helpful?