Skip to content

Commit ff0e12e

Browse files
authored
Create 771-jewels-and-stones.js
1 parent 39620df commit ff0e12e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

771-jewels-and-stones.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* @param {string} J
3+
* @param {string} S
4+
* @return {number}
5+
*/
6+
const numJewelsInStones = function(J, S) {
7+
if(J == null || J === '' || S == null || S === '') return 0
8+
const m = new Set(J)
9+
let res = 0
10+
for(let e of S) {
11+
if(m.has(e)) res++
12+
}
13+
return res
14+
};

0 commit comments

Comments
 (0)