Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
21 lines (18 loc) · 702 Bytes

File metadata and controls

21 lines (18 loc) · 702 Bytes
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package ch08;
import datatype.ListNode;
public class P14_1 {
public ListNode mergeTwoLists(ListNode list1, ListNode list2) {
// 두 노드 중 한쪽이 널이면 널이 아닌 노드를 리턴
if (list1 == null) return list2;
if (list2 == null) return list1;
// l2가 더 크면 l1에 재귀 호출 결과를 엮고 l1을 리턴
if (list1.val < list2.val) {
list1.next = mergeTwoLists(list1.next, list2);
return list1;
// l1이 더 크거나 같으면 l2에 재귀 호출 결과를 엮고 l2를 리턴
} else {
list2.next = mergeTwoLists(list1, list2.next);
return list2;
}
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.