Skip to content

Latest commit

 

History

History
5 lines (3 loc) · 348 Bytes

File metadata and controls

5 lines (3 loc) · 348 Bytes

Idea

Personally I do think this problem is quite similar to 515. Find Largest Value in Each Tree Row.

The idea is to use a stack to keep track of every node we encountered, when level goes up, we just pop item stack.pop() and result.append(stack.pop())