Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdrop.js
More file actions
Latest commit
43 lines (35 loc) · 1.33 KB
/
Copy pathdrop.js
File metadata and controls
43 lines (35 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//set
functionsolution(wordList,keypads){
letresult=[]
letcount=0
for(leti=0;i<keypads.length;i++){//keypadspad outer loop
letkeypadsSet=newSet(keypads[i])
console.log(keypadsSet)
letsetHasChar=false
for(letj=0;j<wordList.length;j++){//inner loop wordList loop
letwordListSet=newSet(wordList[j])//each wordList char
console.log("w",wordListSet)
functioneachWordChar(wordListSet){
console.log("::",wordListSet)
}
wordListSet.forEach(wordListSet=>wordListSet)
console.log("??",wordListSet.forEach(eachWordChar))
// if(keypadsSet.has(wordListSet.forEach(eachWordChar))){
// console.log("???", wordListSet.forEach(eachWordChar))
// setHasChar = true
// } else {
// setHasChar = false
// break;
// }
if(wordList[j].includes(keypads[i][0])&&setHasChar&&k===wordList[j].length-1){
count+=1
}
}//end of inner loop wordList loop
result.push(count)
count=0
}//end of keypadspad outer loop
returnresult
}
solution(['APPLE','PLEAS','PLEASE'],
['AELWXYZ','AELPXYZ','AELPSXY','SAELPRT','XAEBKSY'])
// Expected output: [0, 1, 3, 2, 0]