We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent dd41204 commit 818402eCopy full SHA for 818402e
merge-two-sorted-lists/JEONGBEOMKO.java
@@ -0,0 +1,24 @@
1
+/**
2
+ * Definition for singly-linked list.
3
+ * public class ListNode {
4
+ * int val;
5
+ * ListNode next;
6
+ * ListNode() {}
7
+ * ListNode(int val) { this.val = val; }
8
+ * ListNode(int val, ListNode next) { this.val = val; this.next = next; }
9
+ * }
10
+ */
11
+class Solution {
12
+ public ListNode mergeTwoLists(ListNode list1, ListNode list2) {
13
+ if (list1 == null || list2 == null) {
14
+ return list1 == null ? list2 : list1;
15
+ }
16
+ if (list1.val < list2.val) {
17
+ list1.next = mergeTwoLists(list1.next, list2);
18
+ return list1;
19
+ } else {
20
+ list2.next = mergeTwoLists(list2.next, list1);
21
+ return list2;
22
23
24
+}
0 commit comments