LeetCode. Binary Tree Level Order Traversal [Trees]
Problem: Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example: Given binary tree [3,9,20,null,null,15,7], -Summary- Solve by BFS (Breadth-First Search) Algorithm using queue 1. Create a queue and keep adding the value if left or right subtree exists 2. While adding the value to the queue, we pop and add the value to the..
2020. 6. 7.
LeetCode. Symmetric Tree [Trees]
Problem: Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree [1,2,2,3,4,4,3] is symmetric: But the following [1,2,2,null,3,null,3] is not: -Summary- 1. If a tree has no root or root itself exist, it will always return True 2. Otherwise, we keep check below condition recursively of the Tree's left and right subtree - leftSub..
2020. 6. 7.