Reverse Only Letters
EasyTwo Pointers
Decode it first. Clues, constraints, pattern and plan before any code.Given a string s, reverse only the English letters (a–z and A–Z) and return the result. Every character that is not a letter stays at the same index.
s = "ab-cd" → "dc-ba"
s = "a-bC-dEf-ghIj" → "j-Ih-gfE-dCba"
s = "Test1ng-Leet=code-Q!" → "Qedo1ct-eeLg=ntse-T!"Constraints
1 <= s.length <= 100sconsists of ASCII characters with codes from 33 to 122.scontains no double quotes or backslashes.