Skip to content

Instantly share code, notes, and snippets.

@trantus
Last active January 8, 2019 17:13
Show Gist options
  • Save trantus/594bc336ef89b5e7af89ebbf9318ecaa to your computer and use it in GitHub Desktop.
Save trantus/594bc336ef89b5e7af89ebbf9318ecaa to your computer and use it in GitHub Desktop.
Jewels and Stones
// https://leetcode.com/problems/jewels-and-stones/
var numJewelsInStones = function(J, S) {
let arrJ = J.split("");
let arrS = S.split("");
let counter = 0;
for (let i = 0; i < arrS.length; i++) {
if (arrJ.includes(arrS[i])) {
counter++;
}
}
return counter;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment