Jewels and Stones

July 27, 2020

Jewels and Stones

class Solution {
    public int numJewelsInStones(String jewels, String stones) {
        char[] stoneArray = stones.toCharArray();
        int result = 0;
        for(char j : jewels.toCharArray()){
            for(char s : stoneArray){
                if(s == j){
                    result++;
                }
            }
        }
        return result;
    }
}

Jewels and Stones


Written by @KimHyoJin Tech Blog