From 8c03da857b2770386f4a3f4e5a20f18f7d7c0507 Mon Sep 17 00:00:00 2001 From: yeonjukim164 Date: Sun, 1 Feb 2026 22:45:10 +0900 Subject: [PATCH] =?UTF-8?q?Maximum=20Depth=20of=20Binary=20Tree=20?= =?UTF-8?q?=EB=AC=B8=EC=A0=9C=20=ED=92=80=EC=9D=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- maximum-depth-of-binary-tree/yeonjukim164.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 maximum-depth-of-binary-tree/yeonjukim164.java diff --git a/maximum-depth-of-binary-tree/yeonjukim164.java b/maximum-depth-of-binary-tree/yeonjukim164.java new file mode 100644 index 0000000000..a7078c0104 --- /dev/null +++ b/maximum-depth-of-binary-tree/yeonjukim164.java @@ -0,0 +1,14 @@ +class Solution { + public int maxDepth(TreeNode root) { + // Base Case: 노드가 없으면 깊이는 0 + if (root == null) { + return 0; + } + + // Recursive Step: 왼쪽 깊이와 오른쪽 깊이 중 더 깊은 곳 + 1 (내 키) + int leftDepth = maxDepth(root.left); + int rightDepth = maxDepth(root.right); + + return Math.max(leftDepth, rightDepth) + 1; + } +}