Skip to content

Commit

Permalink
Create 27. 4 Keys Keyboard.py
Browse files Browse the repository at this point in the history
  • Loading branch information
SamirPaulb authored Mar 22, 2024
1 parent e243a6a commit 07c20b2
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# https://www.lintcode.com/problem/867

class Solution:
def max_a(self, n: int) -> int:
dp = [i for i in range(n+1)]
for i in range(4, n+1):
count = 2
prev = i-3
while prev > 0:
dp[i] = max(dp[i], count*dp[prev])
prev -= 1
count += 1
return dp[n]


# Time: O(N^2)
# Space: O(N)

0 comments on commit 07c20b2

Please sign in to comment.