2022-03-27 18:35:17 +08:00
< p > Given two strings < code > s< / code > and < code > t< / code > , return < code > true< / code > < em > if they are equal when both are typed into empty text editors< / em > . < code > ' #' < / code > means a backspace character.< / p >
< p > Note that after backspacing an empty text, the text will continue empty.< / p >
< p > < / p >
2023-12-09 18:42:21 +08:00
< p > < strong class = "example" > Example 1:< / strong > < / p >
2022-03-27 18:35:17 +08:00
< pre >
< strong > Input:< / strong > s = " ab#c" , t = " ad#c"
< strong > Output:< / strong > true
< strong > Explanation:< / strong > Both s and t become " ac" .
< / pre >
2023-12-09 18:42:21 +08:00
< p > < strong class = "example" > Example 2:< / strong > < / p >
2022-03-27 18:35:17 +08:00
< pre >
< strong > Input:< / strong > s = " ab##" , t = " c#d#"
< strong > Output:< / strong > true
< strong > Explanation:< / strong > Both s and t become " " .
< / pre >
2023-12-09 18:42:21 +08:00
< p > < strong class = "example" > Example 3:< / strong > < / p >
2022-03-27 18:35:17 +08:00
< pre >
< strong > Input:< / strong > s = " a#c" , t = " b"
< strong > Output:< / strong > false
< strong > Explanation:< / strong > s becomes " c" while t becomes " b" .
< / pre >
< p > < / p >
< p > < strong > Constraints:< / strong > < / p >
< ul >
< li > < code > < span > 1 < = s.length, t.length < = 200< / span > < / code > < / li >
< li > < span > < code > s< / code > and < code > t< / code > only contain lowercase letters and < code > ' #' < / code > characters.< / span > < / li >
< / ul >
< p > < / p >
< p > < strong > Follow up:< / strong > Can you solve it in < code > O(n)< / code > time and < code > O(1)< / code > space?< / p >