#3823

Reverse Letters Then Special Characters in a String

easy · 81.6% accepted · 46 likes · top 93%

two pointers · string · simulation

⊣ practice⊣ open on leetcode ↗

Description

You are given a string s consisting of lowercase English letters and special characters.

Your task is to perform these in order:

- Reverse the lowercase letters and place them back into the positions originally occupied by letters.

- Reverse the special characters and place them back into the positions originally occupied by special characters.

Return the resulting string after performing the reversals.

Solution