Thursday, August 17, 2017

[Leetcode]Binary Tree Level Order Traversal (AKA BFS)

LC link
Push root to queue then traverse level by level
1. Line 7, 8, old drill, validate input and ask what they want if input is not valid
2. Line 13,   use for loop to simulate level by level visiting
3. line 12, 15, 20,  know what they want for output,
4. Line 14,  queue, FIFO pop(0)   stack FILO pop()

No comments:

Post a Comment