#3612

Process String with Special Operations I

specialist · 650 · lc medium +30 · 65% accepted · 56 likes · top 69%

Description

Process string s (lowercase letters plus '*', '#', '%') left to right, maintaining a result string:

- Lowercase letter: append it to the result.

- '*': remove the last character (if result is non-empty).

- '#': double the result by appending a copy of itself.

- '%': reverse the result.

Return the final result string.

Code

1
2
3