#3823
Reverse Letters Then Special Characters in a String
newbie · 170 · lc easy +15 · 81.6% accepted · 46 likes · top 93%
Description
Given a string s containing lowercase English letters and special characters, perform two independent reversals in order: collect all lowercase letters, reverse them, and write them back into the letter positions; then collect all special characters, reverse them, and write them back into the special-character positions. Return the resulting string.
Code
1
2
3