Class Solution

java.lang.Object
g0901_1000.s0925_long_pressed_name.Solution

public class Solution extends Object
925 - Long Pressed Name.<p>Easy</p> <p>Your friend is typing his <code>name</code> into a keyboard. Sometimes, when typing a character <code>c</code>, the key might get <em>long pressed</em>, and the character will be typed 1 or more times.</p> <p>You examine the <code>typed</code> characters of the keyboard. Return <code>True</code> if it is possible that it was your friends name, with some characters (possibly none) being long pressed.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> name = &ldquo;alex&rdquo;, typed = &ldquo;aaleex&rdquo;</p> <p><strong>Output:</strong> true</p> <p><strong>Explanation:</strong> &lsquo;a&rsquo; and &lsquo;e&rsquo; in &lsquo;alex&rsquo; were long pressed.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> name = &ldquo;saeed&rdquo;, typed = &ldquo;ssaaedd&rdquo;</p> <p><strong>Output:</strong> false</p> <p><strong>Explanation:</strong> &lsquo;e&rsquo; must have been pressed twice, but it was not in the typed output.</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= name.length, typed.length <= 1000</code></li> <li><code>name</code> and <code>typed</code> consist of only lowercase English letters.</li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • isLongPressedName

      public boolean isLongPressedName(String name, String typed)