A text-effects tool applies a list of shift operations to a lowercase string s. Each operation [start, end, direction] shifts every letter from index start to end (both included) one place forward in the alphabet if direction is 1, or one place back if it is 0. Shifting wraps: z forward is a, and a back is z.
Write shiftLetters(s, shifts) that returns the string after all operations.
Input: s = "code", shifts = [[0,1,1],[1,3,0],[0,3,1]] Output: "epde"
Index 0 moves forward twice (c to e), index 1 moves forward once overall (o to p), and indexes 2 and 3 end where they started.
Input: s = "zz", shifts = [[0,1,1]] Output: "aa"
z shifted forward wraps to a.
1 <= s.length <= 5 * 10^40 <= shifts.length <= 5 * 10^40 <= start <= end < s.lengthdirection is 0 or 1.Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #58 Shift Letters by Ranges. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.