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.

  1. Process both strings using a stack.
  2. Compare the final stacks.
  3. Print true or false.

01EXAMPLE 1

Inputs="ab#c", t="ad#c"
Outputtrue

Explanation: Both become "ac".

Constraints

  • O(n + m) time complexity.
Data StructuresStack
JavaScript
Loading...
1 Hidden

Input Arguments

s"ab#c"
t"ad#c"

Expected Output

true

Click RUN to test your solution