Skip to content

Commit

Permalink
Update shifting-letters.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
kamyu104 authored Jun 10, 2018
1 parent a5e1484 commit f0fab42
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions C++/shifting-letters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ class Solution {
auto times = accumulate(shifts.cbegin(), shifts.cend(), 0L) % 26;
for (int i = 0; i < S.length(); ++i) {
result.push_back('a' + (S[i] - 'a' + times) % 26);
times = (times - shifts[i]) % 26;
if (times < 0) {
times += 26;
}
times = ((times - shifts[i]) % 26 + 26) % 26;
}
return result;
}
Expand Down

0 comments on commit f0fab42

Please sign in to comment.