Queue and Stack
Overview
Queue and stack are just like a store. You just want to put and pick the items one by one. The time complexity of put and pick is O(1)
Python makes queue and stack easier because we can use list to finish the functions of queue and stack.
1 | my_queue = [] |
Samples
Travel the tree
No.94 - Binary Tree Inorder Traversal
No.103 - Binary Tree Zigzag Level Order Traversal
Pair Match
No.20 - Valid Parentheses
Store the data in order[Some special questions]
No.42 - Trapping Rain Water
To be continued…