-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdrop.js
More file actions
43 lines (35 loc) · 1.33 KB
/
drop.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
function solution (wordList, keypads){
let result = []
let count = 0
for(let i = 0; i < keypads.length; i++){ //keypadspad outer loop
let keypadsSet = new Set(keypads[i])
console.log(keypadsSet)
let setHasChar = false
for(let j = 0; j < wordList.length; j++){//inner loop wordList loop
let wordListSet = new Set(wordList[j]) //each wordList char
console.log("w", wordListSet)
function eachWordChar(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
return result
}
solution(['APPLE', 'PLEAS', 'PLEASE'],
['AELWXYZ', 'AELPXYZ', 'AELPSXY', 'SAELPRT', 'XAEBKSY'] )
// Expected output: [0, 1, 3, 2, 0]