Created
June 19, 2019 21:38
-
-
Save restart916/393c4c7440042d8961c964928e00367b to your computer and use it in GitHub Desktop.
20190619_leetcode_771_JewelsandStones
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @param {string} J | |
* @param {string} S | |
* @return {number} | |
*/ | |
var numJewelsInStones = function(J, S) { | |
let count = 0 | |
sMap = {} | |
for (let s of S) { | |
if (s in sMap) { | |
sMap[s]++; | |
} else { | |
sMap[s] = 1; | |
} | |
} | |
for (let j of J) { | |
if (j in sMap) { | |
count += sMap[j] | |
} | |
} | |
return count; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
호엥 이 풀이 보니까 제가 진짜 변태적으로 풀었다는 것은 잘 알겠네욬ㅋㅋㅋㅋㅋㅋㅋㅋ