当前位置 : 主页 > 编程语言 > java >

【Leetcode_easy】771. Jewels and Stones

来源:互联网 收集:自由互联 发布时间:2022-07-13
problem ​​771.Jewels and Stones​​ solution1: class Solution { public: int numJewelsInStones(string J, string S) { int res = 0; unordered_setchar js(J.begin(), J.end()); for(auto ch:S) { if(js.find(ch)!=js.end()) res++; } return res;

problem

​​771. Jewels and Stones​​

solution1:

class Solution {
public:
int numJewelsInStones(string J, string S) {
int res = 0;
unordered_set<char> js(J.begin(), J.end());
for(auto ch:S)
{
if(js.find(ch)!=js.end()) res++;
}
return res;
}
};

 

参考

1. ​​Leetcode_easy_771. Jewels and Stones​​;

2. ​​Grandyang​​;

上一篇:【c++基础】ifstream的构造函数
下一篇:没有了
网友评论