Compare Strings With Deletions
OtherBackend Engineer · Technical ScreenLast updated
This question evaluates string processing and algorithmic optimization skills, specifically handling simulated deletions (backspace behavior) and performing comparisons under a strict auxiliary space constraint.
Return whether the two strings are equal after all deletions are applied.
You must implement the comparison without using extra space proportional to the input size. Aim for O(1) auxiliary space.
Example:
Input: s = "ab#c", t = "ad#c"
Output: true
Explanation: Both strings become "ac".
Input: s = "a#c", t = "b"
Output: false
Explanation: The first string becomes "c", while the second becomes "b".
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.