lurenaa的博客

😂代码实现

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
class Solution {
public:
int numJewelsInStones(string J, string S) {
set<char> mp;
for(auto x : J) {
mp.insert(x);
}
int tl = 0;
for(auto a: S) {
if(mp.count(a) > 0) {
tl += 1;
}
}
return tl;
}
};

Accepted

254/254 cases passed (8 ms)

Your runtime beats 25.05 % of cpp submissions

Your memory usage beats 5.26 % of cpp submissions (8.8 MB)