Minimum Time to Type Word Using Special Typewriter LeetCode solution in C++

1
class Solution {
2
public:
3
int minTimeToType(string word) {
4
int res = word.size(), point = 'a';
5
for (auto ch : word) {
6
res += min(abs(ch - point), 26 - abs(point - ch));
7
point = ch;
8
}
9
return res;
10
}
11
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0