java.lang.Object
g1901_2000.s1935_maximum_number_of_words_you_can_type.Solution

public class Solution extends Object
1935 - Maximum Number of Words You Can Type.<p>Easy</p> <p>There is a malfunctioning keyboard where some letter keys do not work. All other keys on the keyboard work properly.</p> <p>Given a string <code>text</code> of words separated by a single space (no leading or trailing spaces) and a string <code>brokenLetters</code> of all <strong>distinct</strong> letter keys that are broken, return <em>the <strong>number of words</strong> in</em> <code>text</code> <em>you can fully type using this keyboard</em>.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> text = &ldquo;hello world&rdquo;, brokenLetters = &ldquo;ad&rdquo;</p> <p><strong>Output:</strong> 1</p> <p><strong>Explanation:</strong> We cannot type &ldquo;world&rdquo; because the &lsquo;d&rsquo; key is broken.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> text = &ldquo;leet code&rdquo;, brokenLetters = &ldquo;lt&rdquo;</p> <p><strong>Output:</strong> 1</p> <p><strong>Explanation:</strong> We cannot type &ldquo;leet&rdquo; because the &lsquo;l&rsquo; and &lsquo;t&rsquo; keys are broken.</p> <p><strong>Example 3:</strong></p> <p><strong>Input:</strong> text = &ldquo;leet code&rdquo;, brokenLetters = &ldquo;e&rdquo;</p> <p><strong>Output:</strong> 0</p> <p><strong>Explanation:</strong> We cannot type either word because the &lsquo;e&rsquo; key is broken.</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= text.length <= 10<sup>4</sup></code></li> <li><code>0 <= brokenLetters.length <= 26</code></li> <li><code>text</code> consists of words separated by a single space without any leading or trailing spaces.</li> <li>Each word only consists of lowercase English letters.</li> <li><code>brokenLetters</code> consists of <strong>distinct</strong> lowercase English letters.</li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • canBeTypedWords

      public int canBeTypedWords(String text, String brokenLetters)