Backspace String Compare
EasyAcc. 94.2%
+20 XP 8
Character Deletion
Processing a string with backspaces is easiest using a stack: push characters, and pop when you see a '#'.
The Assignment
Your function receives s and t.
- Process both strings using a stack.
- Compare the final stacks.
- Print true or false.
01EXAMPLE 1
Input
s="ab#c", t="ad#c"Output
trueExplanation: Both become "ac".
Constraints
- O(n + m) time complexity.
Data StructuresStack
JavaScriptSystem handles I/O — write your function only
Loading...
1 Hidden
Input Arguments
s"ab#c"
t"ad#c"
Expected Output
true
Click RUN to test your solution