Backspace String Compare
Given two strings s and t where '#' means a backspace that deletes the preceding character, return true if the two strings are equal after all backspaces are applied. A backspace on an empty text does nothing.
Open official problem prompt ↗Determine whether two texts typed with a backspace key produce the same final string, without materializing those final strings.
Proofreading two edited documents from the last word backward; every 'delete' mark you meet cancels the next word you would otherwise read, so you only compare the words that actually survived.
- Input
- s = "ab#c", t = "ad#c"
- Output
- true
- Why
- Both reduce to "ac": "ab#c" deletes 'b', "ad#c" deletes 'd'.
1 <= s.length, t.length <= 200s and t only contain lowercase letters and '#' characters