Skip to content

Commit 5b7280e

Browse files
authored
Create 3014. Minimum Number of Pushes to Type Word I.java
1 parent 4eeaaf2 commit 5b7280e

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// O(n)
2+
3+
class Solution {
4+
public int minimumPushes(String word) {
5+
int cnt = word.length()/8;
6+
int min = (word.length() % 8) * (cnt + 1);
7+
int i = 1;
8+
while (cnt > 0) {
9+
min += (8 * i);
10+
i++;
11+
cnt--;
12+
}
13+
return min;
14+
}
15+
}

0 commit comments

Comments
 (0)