3614. Process String with Special Operations II
You are given a string
sconsisting of lowercase English letters and the special characters:'*','#', and'%'.You are also given an integer
k.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
kthcharacter of the final stringresult. Ifkis out of the bounds ofresult, return'.'.
1 |
|