Skip to content

Commit 81568f5

Browse files
authored
Create 1684-count-the-number-of-consistent-strings.js
1 parent 4298ecd commit 81568f5

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* @param {string} allowed
3+
* @param {string[]} words
4+
* @return {number}
5+
*/
6+
var countConsistentStrings = function(allowed, words) {
7+
const set = new Set()
8+
for(let c of allowed) set.add(c)
9+
let res = 0
10+
for(let i = 0, len = words.length; i < len; i++) {
11+
const cur = words[i]
12+
let b = true
13+
for(let c of cur) {
14+
if(!set.has(c)) {
15+
b = false
16+
break
17+
}
18+
}
19+
if(b) res++
20+
}
21+
22+
return res
23+
};

0 commit comments

Comments
 (0)