1427. Perform String Shifts

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 1427

class Solution:
    def stringShift(self, s: str, shift: List[List[int]]) -> str:
        x = sum((b if a else -b) for a, b in shift)
        x %= len(s)
        return s[-x:] + s[:-x]