tree
LeetCode / Tree / 543번 / Diameter of Binary Tree / JS
Diameter of Binary Tree - LeetCode Can you solve this real interview question? Diameter of Binary Tree - Given the root of a binary tree, return the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path leetcode.com diameter를 직역하면 지름이라는 뜻인데... 이 문제에서 지름을 반환하면 된다(?). 문제에서 나타내는 diameter..
LeetCode / Tree / 110번 / Balanced Binary Tree / JS
Balanced Binary Tree - LeetCode Can you solve this real interview question? Balanced Binary Tree - Given a binary tree, determine if it is height-balanced. Example 1: [https://assets.leetcode.com/uploads/2020/10/06/balance_1.jpg] Input: root = [3,9,20,null,null,15,7] Output: true Exam leetcode.com 균형잡힌 이진트리인지 boolean 값으로 반환하는 문제이다. 여기서 균형잡힌 이진트리란, 왼쪽과 오른쪽의 subtree의 depth가..
LeetCode / Tree / 226번 / Invert Binary Tree / JS
Invert Binary Tree - LeetCode Can you solve this real interview question? Invert Binary Tree - Given the root of a binary tree, invert the tree, and return its root. Example 1: [https://assets.leetcode.com/uploads/2021/03/14/invert1-tree.jpg] Input: root = [4,2,7,1,3,6,9] Output: [4 leetcode.com 주어진 트리를 좌우반전시켜 반환하는 문제이다. /** * Definition for a binary tree node. * function..
LeetCode / Tree / 102번 / Binary Tree Level Order Traversal / JS
Binary Tree Level Order Traversal - LeetCode Can you solve this real interview question? Binary Tree Level Order Traversal - Given the root of a binary tree, return the level order traversal of its nodes' values. (i.e., from left to right, level by level). Example 1: [https://assets.leetcode.com/u leetcode.com Level Order, 즉 한 Level(=depth)씩 탐색하는 문제이다. BFS와 같다. /** * Defi..
LeetCode / Tree / 589번 / N-ary Tree Preorder Traversal / JS
N-ary Tree Preorder Traversal - LeetCode Can you solve this real interview question? N-ary Tree Preorder Traversal - Given the root of an n-ary tree, return the preorder traversal of its nodes' values. Nary-Tree input serialization is represented in their level order traversal. Each group of chil leetcode.com 전위순회로 트리를 탐색하는 문제이다. 전위순회의 순서는 왼쪽 하위노드 -> 루트 -> 오른쪽 하위노드의 순서이다...