-
[LeetCode] Merge Two Sorted List알고리즘 2019. 9. 21. 01:49
문제
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.
Example:
Input: 1->2->4, 1->3->4 Output: 1->1->2->3->4->4
Approach
https://noname122.tistory.com/9?category=851290
이 문제의 하위호환격인 문제
input인 l1과 l2가 NULL인지 확인한 다음
두 리스트에서 작은 값부터 가져와서 답 리스트에 붙여주면 된다.
Code
https://github.com/chi3236/algorithm/blob/master/LeetCode_MergeTwoSortedList.cpp
'알고리즘' 카테고리의 다른 글
[LeetCode] Letter Combinations of a Phone Number (0) 2019.09.21 [LeetCode] Container With Most Water (0) 2019.09.21 [LeetCode] Regular Expression Matching (0) 2019.09.21 [LeetCode] Longest Common Prefix (0) 2019.09.20 [LeetCode] String to Int (0) 2019.09.20