Tree

문제 Given the root of a binary tree, return its maximum depth. A binary tree's maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. Example 1: Input: root = [3,9,20,null,null,15,7] Output: 3Example 2: Input: root = [1,null,2] Output: 2Example 3: Input: root = [] Output: 0Example 4: Input: root = [0] Output: 1Constraints: The number of ..
문제 Given two binary trees, write a function to check if they are the same or not. Two binary trees are considered the same if they are structurally identical and the nodes have the same value. Example 1: Input: 1 1 / \ / \ 2 3 2 3 [1,2,3], [1,2,3] Output: trueExample 2: Input: 1 1 / \ 2 2 [1,2], [1,null,2] Output: falseExample 3: Input: 1 1 / \ / \ 2 1 1 2 [1,2,1], [1,1,2] Output: false풀이 class ..
쓴웃음
'Tree' 태그의 글 목록