Skip to content

Commit b2aab49

Browse files
committed
Add solution #1935
1 parent 39125fc commit b2aab49

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@
190190
1780|[Check if Number is a Sum of Powers of Three](./1780-check-if-number-is-a-sum-of-powers-of-three.js)|Medium|
191191
1880|[Check if Word Equals Summation of Two Words](./1880-check-if-word-equals-summation-of-two-words.js)|Easy|
192192
1929|[Concatenation of Array](./1929-concatenation-of-array.js)|Easy|
193+
1935|[Maximum Number of Words You Can Type](./1935-maximum-number-of-words-you-can-type.js)|Easy|
193194
2000|[Reverse Prefix of Word](./2000-reverse-prefix-of-word.js)|Easy|
194195
2016|[Maximum Difference Between Increasing Elements](./2016-maximum-difference-between-increasing-elements.js)|Easy|
195196

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* 1935. Maximum Number of Words You Can Type
3+
* https://leetcode.com/problems/maximum-number-of-words-you-can-type/
4+
* Difficulty: Easy
5+
*
6+
* There is a malfunctioning keyboard where some letter keys do not work.
7+
* All other keys on the keyboard work properly.
8+
*
9+
* Given a string text of words separated by a single space (no leading or
10+
* trailing spaces) and a string brokenLetters of all distinct letter keys
11+
* that are broken, return the number of words in text you can fully type
12+
* using this keyboard.
13+
*/
14+
15+
/**
16+
* @param {string} text
17+
* @param {string} brokenLetters
18+
* @return {number}
19+
*/
20+
var canBeTypedWords = function(text, brokenLetters) {
21+
return text
22+
.split(/\s+/)
23+
.filter(word => !brokenLetters.split('').some(s => word.includes(s)))
24+
.length;
25+
};

0 commit comments

Comments
 (0)