We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4a2c349 commit 76b63adCopy full SHA for 76b63ad
merge-two-sorted-lists/kimjunyoung90.java
@@ -0,0 +1,25 @@
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
+}
18
+
19
+class ListNode {
20
+ int val;
21
+ ListNode next;
22
+ ListNode() {}
23
+ ListNode(int val) { this.val = val; }
24
+ ListNode(int val, ListNode next) { this.val = val; this.next = next; }
25
0 commit comments