Skip to content

Commit f53a921

Browse files
Merge pull request #2146 from kimjunyoung90/main
[kimjunyoung90] WEEK 04 solutions
2 parents aa44e4b + b7ad44a commit f53a921

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
public class Solution {
2+
public int maxDepth(TreeNode root) {
3+
if (root == null) return 0;
4+
return 1 + Math.max(maxDepth(root.left), maxDepth(root.right));
5+
}
6+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
public class Solution {
2+
public ListNode mergeTwoLists(ListNode list1, ListNode list2) {
3+
//1. null 체크
4+
if(list1 == null || list2 == null) {
5+
return list1 != null ? list1 : list2;
6+
}
7+
//1. 값 비교
8+
if(list1.val < list2.val) {
9+
//다음 Node 비교
10+
list1.next = mergeTwoLists(list1.next, list2);
11+
return list1;
12+
} else {
13+
list2.next = mergeTwoLists(list1, list2.next);
14+
return list2;
15+
}
16+
}
17+
}

0 commit comments

Comments
 (0)