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
This discussion was converted from issue #78 on September 15, 2026 11:05.
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.
Problem link
https://leetcode.com/problems/maximum-score-of-spliced-array/
Problem Summary
배열 2개가 주어지고, 배열의 일부 구간을 다른 배열과 swap 가능할 때 두 배열의 합 중 최대가 가장 큰 값을 구하는 문제.
Solution
딱 보니 DP라서 처음에는 top-down으로 풀었다.
해당 최댓값은 배열 하나에만 계산되므로 배열 2개를 서로 바꿔서 한번 더 돌려주면 된다.
정답이 나오긴 하는데 2792 ms로 하위 5%의 성능..
결국 bottom-up 으로 다시 제출해서 성능 2배 개선, 메모리도 대폭 줄였다 (1차원 DP)
참고로 discuss를 보면 Kadane알고리즘이라는 것도 있는데... 어차피 DP도 O(n) 이라 성능 차이는 별로 없다.
(https://leetcode.com/problems/maximum-score-of-spliced-array/discuss/2199139/100-fasteror-Most-Detailed-solution-for-complete-dummiesor-O(n)-Kadane's-single-loop)
Source Code
Bottom-Up (1264 ms / 31.5MB)
Top-Down (2792 ms / 517.1 MB)
All reactions