leetcode711

水题没什么好说的

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
class Solution {
public int numJewelsInStones(String j, String s) {
short[] a = new short[256];
for(short i=0;i<256;i++){
a[i] = 0;
}
int length = s.length();
for(short i=0;i<length;i++){
a[s.charAt(i)]++;
}
length = j.length();
int sum = 0;
for(short i=0;i<length;i++){
sum = sum+a[j.charAt(i)];
}
return sum;
}
}