Skip to content

Commit

Permalink
Create 650. 2 Keys Keyboard
Browse files Browse the repository at this point in the history
  • Loading branch information
Chayandas07 authored Aug 19, 2024
1 parent 92833f5 commit 517a971
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions 650. 2 Keys Keyboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class Solution {
public:
int minSteps(int n) {
int curr = 1;
int copy = 0;
int steps = 0;

while(curr<n){
if((n-curr)%curr==0){
copy = curr;
steps += 2;
}
else{
steps += 1;
}
curr += copy;
}

return steps;
}
};

0 comments on commit 517a971

Please sign in to comment.