Skip to main content

Leetcode - 771. Jewels and Stones

· One min read

https://leetcode.com/problems/jewels-and-stones/

/**
* @param {string} jewels
* @param {string} stones
* @return {number}
*/
var numJewelsInStones = function (jewels, stones) {
let result = 0;
for (let i = 0; i < stones.length; i++) {
if (jewels.includes(stones[i])) {
result++;
}
}
return result;
};

Runtime: 95 ms, faster than 62.67% of JavaScript online submissions for Jewels and Stones.

Memory Usage: 41.9 MB, less than 93.79% of JavaScript online submissions for Jewels and Stones.