MCPcopy Create free account
hub / github.com/Tiwarishashwat/InterviewCodes / Solution

Class Solution

JewelsAndStones.java:1–19  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1class Solution {
2 public int numJewelsInStones(String jewels, String stones) {
3// Calculating frequency
4 int charFreq[] = new int[256];
5 for(int i=0;i<stones.length();i++)
6 {
7 charFreq[stones.charAt(i)-65]++;
8 }
9
10// for storing result
11 int count=0;
12
13 for(int i=0;i<jewels.length();i++)
14 {
15 count+=charFreq[jewels.charAt(i)-65];
16 }
17 return count;
18 }
19}
20
21
22

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected