A typing test records every key press as a string, where # stands for the backspace key. Backspace removes the character before it, if there is one; a backspace on empty text does nothing.
Write sameText(a, b) that returns true if both recordings produce the same final text, and false otherwise.
Input: a = "ab#c", b = "ad#c" Output: true
Both produce ac.
Input: a = "a#c", b = "b" Output: false
The first produces c and the second b.
0 <= a.length, b.length <= 2 * 10^5a and b have lowercase letters and #.Run tries your code on the examples. Submit runs every test, including hidden edge cases and big inputs that check your code is fast enough, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #250 Compare Typed Text With Backspaces. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.