X. Perform String Shifts
Easy
😇 Solution
class Solution:
def stringShift(self, s: str, shift: List[List[int]]) -> str:
for i in range(len(shift)):
direction,amount = shift[i]
if direction == 0:
s = s[amount:]+s[:amount]
if direction == 1:
s = s[-amount:] + s[:-amount]
return sLast updated