Backspace String Compare
Given two strings S andT, return if they are equal when both are typed into empty text editors.#means a backspace character.
Example 1:
Input:
S =
"ab#c"
, T =
"ad#c"
Output:
true
Explanation
: Both S and T become "ac".Example 2:
Input:
S =
"ab##"
, T =
"c#d#"
Output:
true
Explanation
: Both S and T become "".Example 3:
Example 4:
Note:
分析
栈内只加字母,不加#,遇到‘#’,抵消栈内char,字母的话加入。 最后比较S,T剩下的东西
Last updated
Was this helpful?