-
[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
[LeetCode] Median of Two Sorted Array
문제 There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). You may assume nums1..
noname122.tistory.com
이 문제의 하위호환격인 문제
input인 l1과 l2가 NULL인지 확인한 다음
두 리스트에서 작은 값부터 가져와서 답 리스트에 붙여주면 된다.
Code
https://github.com/chi3236/algorithm/blob/master/LeetCode_MergeTwoSortedList.cpp
chi3236/algorithm
Contribute to chi3236/algorithm development by creating an account on GitHub.
github.com
'알고리즘' 카테고리의 다른 글
[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