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 #141 on September 15, 2026 11:12.
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/2-keys-keyboard/
Problem Summary
복사, 붙여넣기만 가능한 키보드에서 특정 길이를 만드는 최소 횟수를 구하는 문제
Solution
일단 간단히 DP로 풀리긴 한다. dp[i][j] = i길이를 j만큼 붙여넣어 만들때 최소 횟수. O(n^2)
그런데 여기서 수학적으로 접근하면 O(n)으로 가능하다.
자세한건 에디토리얼 참고.
Source Code
All reactions