File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed
maximum-depth-of-binary-tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -26,13 +26,13 @@ func maxDepth(root *TreeNode) int {
2626```
2727- - -
2828# Intuition
29- Implement Stack can be troublesome, but it is effective to problem that require tracking depths or levels.
29+ Implement Queue can be troublesome, but it is effective to problem that require tracking depths or levels.
3030<!-- Describe your first thoughts on how to solve this problem. -->
3131
3232# Approach
3333<!-- Describe your approach to solving the problem. -->
34- 1 . Maintain Element belonging to the same level in the stack .
35- 2 . While Iterating through the stack , remove the current level and save the next level.
34+ 1 . Maintain Element belonging to the same level in the queue .
35+ 2 . While Iterating through the queue , remove the current level and save the next level.
3636- In GoLang, ` range for loop ` capture only first once. So We can maintain current level's easily.
37373 . increase depth while iterationg through all elements until the end.
3838# Complexity
You can’t perform that action at this time.
0 commit comments