Tap here to switch tabs
Problem
Submissions

Problem: Process String with Special Operations I

med
30 min
Try to solve the Process String with Special Operations I problem.

Statement

You are given a string s consisting of lowercase English letters and special characters *, #, and %.

Process the characters of s sequentially from left to right to build a result string, starting with an empty string:

  • If the character is a lowercase English letter, append it to the end of the result string.

  • If the character is *, remove the last character from the result string.

  • If the character is #, duplicate the entire current result string.

  • If the character is %, reverse the entire current result string.

Return the final string after processing all characters in s.

Constraints:

  • 1≤1 \leq s.length ≤20\leq 20

  • s consists only of lowercase English letters and the characters *, #, and %.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Process String with Special Operations I

med
30 min
Try to solve the Process String with Special Operations I problem.

Statement

You are given a string s consisting of lowercase English letters and special characters *, #, and %.

Process the characters of s sequentially from left to right to build a result string, starting with an empty string:

  • If the character is a lowercase English letter, append it to the end of the result string.

  • If the character is *, remove the last character from the result string.

  • If the character is #, duplicate the entire current result string.

  • If the character is %, reverse the entire current result string.

Return the final string after processing all characters in s.

Constraints:

  • 1≤1 \leq s.length ≤20\leq 20

  • s consists only of lowercase English letters and the characters *, #, and %.