class Solution {
public:
string shiftingLetters(string S, vector<int>& shifts) {
int sum = 0;
for(int i = shifts.size()- 1; i>=0; --i)
{
S[i] = (S[i] - 'a' + (sum + shifts[i])%26)%26 + 'a';
sum = (sum + shifts[i])%26;
}
return S;
}
};
网友评论