:type S: str :type shifts: List[int] :rtype: str
(self, S, shifts)
| 41 | """ |
| 42 | class Solution(object): |
| 43 | def shiftingLetters(self, S, shifts): |
| 44 | """ |
| 45 | :type S: str |
| 46 | :type shifts: List[int] |
| 47 | :rtype: str |
| 48 | """ |
| 49 | |
| 50 | letters = "abcdefghijklmnopqrstuvwxyz" |
| 51 | |
| 52 | new_s = [] |
| 53 | old_index = 0 |
| 54 | for i, j in zip(S[::-1], shifts[::-1]): |
| 55 | index = letters.index(i) |
| 56 | |
| 57 | new_index = (index+j+old_index)%26 |
| 58 | |
| 59 | new_s.append(letters[new_index]) |
| 60 | old_index += j |
| 61 | return ''.join(new_s[::-1]) |
| 62 |
nothing calls this directly
no outgoing calls
no test coverage detected