You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
간단한 해결책으로는 모든 리스트를 하나로 붙인 다음 정렬하는 것이다. 시간 복잡도는 O(N logN)이고 충분히 빨리 동작한다.
풀이를 보니 분할 정복 풀이가 정석인 것 같아서 분할 정복 스타일로 다시 풀었는데 이게 시간, 공간이 더 크다는??
재귀 방식으로 풀었고 가운데를 잘라서 왼쪽 부분 오른쪽 부분을 머지한 결과를 머지하는 방식으로 동작한다. 추가 메모리를 사용하지 않기 위해 left 에다 머지한 결과를 덮어 씌우는 식으로 구현하였다.
This discussion was converted from issue #7 on September 15, 2026 10:57.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Problem link
https://leetcode.com/problems/merge-k-sorted-lists/
Problem Summary
k개의 정렬된 리스트를 하나의 정렬된 리스트로 머지하는 문제.
Solution
간단한 해결책으로는 모든 리스트를 하나로 붙인 다음 정렬하는 것이다. 시간 복잡도는 O(N logN)이고 충분히 빨리 동작한다.
풀이를 보니 분할 정복 풀이가 정석인 것 같아서 분할 정복 스타일로 다시 풀었는데 이게 시간, 공간이 더 크다는??
재귀 방식으로 풀었고 가운데를 잘라서 왼쪽 부분 오른쪽 부분을 머지한 결과를 머지하는 방식으로 동작한다. 추가 메모리를 사용하지 않기 위해 left 에다 머지한 결과를 덮어 씌우는 식으로 구현하였다.
더 다양한 풀이는 공식 솔루션 참고.
https://leetcode.com/problems/merge-k-sorted-lists/solution/
Source Code
All reactions