Re Given Strings J Representing Types Stones Jewels S Representing Stones Character Sis T Q30737960
You’re given strings J representing the types of stones that arejewels, and S representing the stones you have. Each character inSis a type of stone you have. You want to know how many of thestones you have are also jewels. The letters in J are guaranteeddistinct, and all characters in J and S are letters. Letters arecase sensitive, so “a” is considered a different type of stone from”A”. Example 1: Input: J = “aA”, S = “aAAbbbb” Output: 3 Example 2:Input: J = “z”, S = “ZZ” Output: 0
public class JewelsAndStones { public int JewelsInStones(Stringj, String S) {
boolean[] isJ = new boolean[128]; for (char c: J.toCharArray()){
isJ[c] = true; }
int count=0; for(char c: S.toCharArray()){ if (isJ[c])count++;
}
return count;
} public static void main(Strings[] args) {
JewelsAndStones sol = new JewelsAndStones();
System.out.println(sol.numJeweInStones(J: “aA” , S: “aAAAbbb”));
}
}
I have written this code for above question… It is showingerror for strings