/** * @param {string} J * @param {string} S * @return {number} */ var numJewelsInStones = function(J, S) { const jewels = new Set([...J]) return S.split('').reduce((res, s) => res + jewels.has(s), 0); };
从一堆石头中,去寻找珠宝。
/** * @param {string} J * @param {string} S * @return {number} */ var numJewelsInStones = function(J, S) { const jewels = new Set([...J]) return S.split('').reduce((res, s) => res + jewels.has(s), 0); };
从一堆石头中,去寻找珠宝。