class Solution { public String shiftingLetters(String s, int[] shifts) { int shiftCount = 0; char[] chars = s.toCharArray(); for (int i = chars.length - 1; i >= 0; i--) { shiftCount += shifts[i] % 26; chars[i] = (char) ('a' + (chars[i] - 'a' + shiftCount) % 26); } return new String(chars); } }
|