2 Keys Keyboard
Input:
3
Output:
3
Explanation:
Intitally, we have one character 'A'.
In step 1, we use
Copy All
operation.
In step 2, we use
Paste
operation to get 'AA'.
In step 3, we use
Paste
operation to get 'AAA'.Last updated
Input:
3
Output:
3
Explanation:
Intitally, we have one character 'A'.
In step 1, we use
Copy All
operation.
In step 2, we use
Paste
operation to get 'AA'.
In step 3, we use
Paste
operation to get 'AAA'.Last updated
class Solution:
def minSteps(self, n: int) -> int:
#greedy
res = 0
if n == 1:
return 0
for i in range(2,n+1):
while n%i == 0:
res+=i
n/=i
return res