Maximum Depth of Binary Tree
Recursive Call
Last updated
Was this helpful?
Recursive Call
Last updated
Was this helpful?
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.
์๋ฃ๊ตฌ์กฐ : N/A
์๊ณ ๋ฆฌ์ฆ 1. ์ฌ๊ทํธ์ถ์ ํตํด ์๋ ธ๋๊น์ง ๋ด๋ ค๊ฐ๋ค. - Null์ ๋ง๋ ๋๊น์ง ์ฌ๊ทํธ์ถ๋ก ์ญ ๋ด๋ ค๊ฐ๋ค! 2. Null์ ๋ง๋๋ฉด ๋น๋ก์ ๊ฐ์ ๊ฐ์ง๊ฒ ๋๋ค! 0 ๋๋ 1. - left:0, right:0, Math.max(0,0)+1 = 1
์๊ณ ๋ฆฌ์ฆ์ Java๋ก