Class Solution

  • All Implemented Interfaces:

    
    public final class Solution
    
                        

    3612 - Process String with Special Operations I.

    Medium

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

    Build a new string result by processing s according to the following rules from left to right:

    • If the letter is a lowercase English letter append it to result.

    • A '*' removes the last character from result, if it exists.

    • A '#' duplicates the current result and appends it to itself.

    • A '%' reverses the current result.

    Return the final string result after processing all characters in s.

    Example 1:

    Input: s = "a#b%\*"

    Output: "ba"

    Explanation:

    Thus, the final result is "ba".

    Example 2:

    Input: s = "z\*#"

    Output: ""

    Explanation:

    Thus, the final result is "".

    Constraints:

    • 1 <= s.length <= 20

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

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
      Solution()
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final String processStr(String s)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait