#C9635. Process Backspaces in a String
Process Backspaces in a String
Process Backspaces in a String
You are given a string s
that contains lowercase letters and the character '#' which represents a backspace. Your task is to process the string by interpreting each '#' as a backspace operation that deletes the character immediately before it. If there is no character to delete, the '#' does nothing. Finally, output the resulting string after all backspace operations have been applied.
For example, given the string "abc#d##"
, the final string would be "a"
.
Note: The backspace operation can be thought of in terms of stack operations where a push occurs for each regular character and a pop occurs whenever a '#' is encountered (provided the stack is not empty). In LaTeX, you might express the core idea as:
$$ S = \text{process}(s) $$
inputFormat
The input consists of a single line containing the string s
which consists of lowercase letters and the '#' character representing a backspace.
You should read from standard input (stdin).
outputFormat
Output the processed string after applying all the backspace operations. Write your result to standard output (stdout).
## samplea#