Skip to content

Commit

Permalink
Add solution for 2 Keys Keyboard
Browse files Browse the repository at this point in the history
  • Loading branch information
Blacknahil committed Aug 19, 2024
1 parent 34af2e0 commit bb52727
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions camp1/week3/leetcode/2-keys-keyboard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class Solution:
def minSteps(self, n: int) -> int:
cur=1
count=0
last=1
while cur<n:
if n%cur==0:
count+=2
last=cur
cur*=2
# print("cur",cur,"count",count,"last",last)
else:
count+=1
cur+=last
# print("cur",cur,"count",count,"last",last)
# print(last,cur,count)
return count






0 comments on commit bb52727

Please sign in to comment.