A text effect in a slide editor reverses the order of the letters in a label but leaves every other character (digits, spaces, punctuation) exactly where it was.
Write flipLetters(label) that returns the new label. A letter is any of a-z or A-Z; letters keep their case.
Input: label = "ab-cd" Output: "dc-ba"
The letters abcd are reversed to dcba, and the dash stays at index 2.
Input: label = "v2-Beta!" Output: "a2-teBv!"
The digit, dash, and ! stay in place; the letters vBeta become ateBv.
0 <= label.length <= 100000label contains printable ASCII characters.Run tries your code on the examples. Submit runs every test, including hidden edge cases and big inputs that check your code is fast enough, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #99 Flip Only the Letters. 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.