Class Solution
-
- All Implemented Interfaces:
public final class Solution3612 - Process String with Special Operations I.
Medium
You are given a string
sconsisting of lowercase English letters and the special characters:*,#, and%.Build a new string
resultby processingsaccording 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 fromresult, if it exists.A
'#'duplicates the currentresultand appends it to itself.A
'%'reverses the currentresult.
Return the final string
resultafter processing all characters ins.Example 1:
Input: s = "a#b%\*"
Output: "ba"
Explanation:
Thus, the final
resultis"ba".Example 2:
Input: s = "z\*#"
Output: ""
Explanation:
Thus, the final
resultis"".Constraints:
1 <= s.length <= 20sconsists of only lowercase English letters and special characters*,#, and%.
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
Method Summary
Modifier and Type Method Description final StringprocessStr(String s)-
-
Method Detail
-
processStr
final String processStr(String s)
-
-
-
-