LeetCode 771. Jewels and Stones Posted on 2021-01-21 In LeetCode 題目12Input: jewels = "aA", stones = "aAAbbbb"Output: 3 解法思維跑迴圈比對 123456789101112var numJewelsInStones = function(jewels, stones) { let c=0 for (const jew of jewels) { for (const ston of stones) { if(jew==ston){ c++ } } } return c}; 先解構再用filter()篩選 1234var numJewelsInStones = function(jewels, stones) { let s=[...stones].filter((item)=>jewels.includes(item)) return s.length};