FunctionRacerProblemsRace

Reverse Only Letters

EasyStringsPython, JavaScript, TypeScript, Java, C++

Return a string where the letters of s appear in reverse order, but every character that is not a letter (digits, dashes and so on) stays at its original position.

Example 1

s "a-bC-dEf"
returns "f-Ed-Cba"

Letters abCdEf reversed are fEdCba, placed back into the letter slots: f-Ed-Cba.

Example 2

s "12ab"
returns "12ba"

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Strings problems