cswork / OA打开练习工作台

Goldman SachsOA #3

Backspace String Compare

简单可在线判题

考点(AI 标注)单调栈与堆字符串

Given two strings consisting only of lowercase English letters and #. # is a backspace that deletes the single character immediately before it in the current string; if the string is empty at that moment, it has no effect. Determine whether the two strings are equal after each is processed; output 1 if they are equal, otherwise output 0.

输入格式

Two lines with the non-empty strings s1 and s2. Complete original constraints: 1≤|s1|,|s2|≤200000; characters are only lowercase English letters or #. The ranges come from the complete raw of the fixed submission; the 1 5 in the compiled MDX is a corrupted fragment. The two-line standard input/output is this site's wrapper.

输出格式

Output 1 if they are equal, otherwise output 0.

样例 1

输入:

axx#b#b#c
axbdf#c#c

输出:

0

样例说明

A backspace on an empty string does nothing; all other rules follow the original definition. You can scan from right to left while counting characters to skip, or use a stack.