프로그래밍-코딩테스트/LeetCode

[Tree] Maximum Depth of Binary Tree

개발자1344 2021. 1. 25. 22:30

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.

 

트리의 최대 depth를 구하는 문제

 

일종의 카데인 알고리즘으로 풀어냈다

input노드의 최대 뎁스는 left뎁스와 right뎁스의 최대 뎁스에 1을 더한것이다