😎풀이

  1. root 노드의 값을 구함
  2. 좌측 leaf 노드의 값을 구함
  3. 우측 leaf 노드의 값을 구함
  4. leaves 노드의 합을 root 노드 값과 동등 비교
function checkTree(root: TreeNode | null): boolean {
    return root.val === root.left.val + root.right.val
};
profile
내 지식을 공유할 수 있는 대담함

0개의 댓글