Tap here to switch tabs
Problem
Submissions

Problem: Perform String Shifts

med
30 min
Try to solve the Perform String Shifts problem.

Statement

You are given a string s containing lowercase English letters and a 2extD2 ext{D} array shift where shift[i] = [direction_i, amount_i].

Each operation shifts the string s according to the following rules:

  • If direction_i =0= 0, shift the string s to the left by amount_i positions. A left shift of 11 moves the first character of s to the end.

  • If direction_i =1= 1, shift the string s to the right by amount_i positions. A right shift of 11 moves the last character of s to the beginning.

Return the resulting string after performing all shift operations on s in the given order.

Constraints:

  • 1≤1 \leq s.length ≤100\leq 100

  • s only contains lowercase English letters.

  • 1≤1 \leq shift.length ≤100\leq 100

  • shift[i].length =2= 2

  • direction_i is either 00 or 11.

  • 0≤0 \leq amount_i ≤100\leq 100

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Perform String Shifts

med
30 min
Try to solve the Perform String Shifts problem.

Statement

You are given a string s containing lowercase English letters and a 2extD2 ext{D} array shift where shift[i] = [direction_i, amount_i].

Each operation shifts the string s according to the following rules:

  • If direction_i =0= 0, shift the string s to the left by amount_i positions. A left shift of 11 moves the first character of s to the end.

  • If direction_i =1= 1, shift the string s to the right by amount_i positions. A right shift of 11 moves the last character of s to the beginning.

Return the resulting string after performing all shift operations on s in the given order.

Constraints:

  • 1≤1 \leq s.length ≤100\leq 100

  • s only contains lowercase English letters.

  • 1≤1 \leq shift.length ≤100\leq 100

  • shift[i].length =2= 2

  • direction_i is either 00 or 11.

  • 0≤0 \leq amount_i ≤100\leq 100