Skip to content

Latest commit

 

History

History
20 lines (17 loc) · 408 Bytes

File metadata and controls

20 lines (17 loc) · 408 Bytes

0917. Reverse Only Letters

Given a string s, return the "reversed" string where all characters that are not a letter stay in the same place, and all letters reverse their positions.

Example 1:

Input: s = "ab-cd"
Output: "dc-ba"

Example 2:

Input: s = "a-bC-dEf-ghIj"
Output: "j-Ih-gfE-dCba"

Example 3:

Input: s = "Test1ng-Leet=code-Q!"
Output: "Qedo1ct-eeLg=ntse-T!"