【字符串】848. 字母移位
作者:互联网
题目:
解答:
1 class Solution { 2 public: 3 string shiftingLetters(string S, vector<int>& shifts) 4 { 5 int size = (int)S.size(); 6 int cnt = 0; 7 for (int i = size - 1; i >= 0;i--) 8 { 9 cnt += shifts[i] % 26; 10 int index = S[i] - 'a' + cnt; 11 S[i] = (index % 26) + 'a'; 12 } 13 return S; 14 } 15 };
标签:index,cnt,int,26,848,shifts,字符串,移位,size 来源: https://www.cnblogs.com/ocpc/p/12826186.html