java.lang.Object
g0801_0900.s0844_backspace_string_compare.Solution

public class Solution extends Object
844 - Backspace String Compare.<p>Easy</p> <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><strong>Example 1:</strong></p> <p><strong>Input:</strong> s = &ldquo;ab#c&rdquo;, t = &ldquo;ad#c&rdquo;</p> <p><strong>Output:</strong> true</p> <p><strong>Explanation:</strong> Both s and t become &ldquo;ac&rdquo;.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> s = &ldquo;ab##&rdquo;, t = &ldquo;c#d#&rdquo;</p> <p><strong>Output:</strong> true</p> <p><strong>Explanation:</strong> Both s and t become &quot;&quot;.</p> <p><strong>Example 3:</strong></p> <p><strong>Input:</strong> s = &ldquo;a#c&rdquo;, t = &ldquo;b&rdquo;</p> <p><strong>Output:</strong> false</p> <p><strong>Explanation:</strong> s becomes &ldquo;c&rdquo; while t becomes &ldquo;b&rdquo;.</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= s.length, t.length <= 200</code></li> <li><code>s</code> and <code>t</code> only contain lowercase letters and <code>'#'</code> characters.</li> </ul> <p><strong>Follow up:</strong> Can you solve it in <code>O(n)</code> time and <code>O(1)</code> space?</p>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • backspaceCompare

      public boolean backspaceCompare(String s, String t)