Skip to content

Commit 1c8632f

Browse files
authored
Create Minimum Number of Pushes to Type Word I.java
1 parent c674418 commit 1c8632f

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution {
2+
public int minimumPushes(String word) {
3+
int pushes = 0;
4+
int idx = 0;
5+
int multiple = 1;
6+
while (idx < word.length()) {
7+
int count = Math.min(8, word.length() - idx);
8+
pushes += count * multiple;
9+
multiple++;
10+
idx += count;
11+
}
12+
return pushes;
13+
}
14+
}

0 commit comments

Comments
 (0)