Jewels and Stones】的更多相关文章

Jewels and Stones You're given strings J representing the types of stones that are jewels, and S representing the stones you have.  Each character inS is a type of stone you have.  You want to know how many of the stones you have are also jewels. The…
题目描述 给定字符串J 代表石头中宝石的类型,和字符串 S代表你拥有的石头. S 中每个字符代表了一种你拥有的石头的类型,你想知道你拥有的石头中有多少是宝石. J 中的字母不重复,J 和 S中的所有字符都是字母.字母区分大小写,因此"a"和"A"是不同类型的石头. 示例 1: 输入: J = "aA", S = "aAAbbbb" 输出: 3 示例 2: 输入: J = "z", S = "ZZ&…
Jewels and Stones Description You're given strings J representing the types of stones that are jewels, and S representing the stones you have. Each character in S is a type of stone you have. You want to know how many of the stones you have are also…
problem 771. Jewels and Stones solution1: class Solution { public: int numJewelsInStones(string J, string S) { ; 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…
Question 771. Jewels and Stones Solution 题目大意:两个字符串J和S,其中J中每个字符不同,求S中包含有J中字符的个数,重复的也算 思路:Set记录字符串J中的每个字符,遍历S中的字符,如果出现在Set中,count加1 Java实现: public int numJewelsInStones(String J, String S) { Set<Character> set = new HashSet<>(); int count = 0;…
Soma is a fashionable girl. She absolutely loves shiny stones that she can put on as jewellery accessories. She has been collecting stones since her childhood - now she has become really good with identifying which ones are fake and which ones are no…
You're given strings J representing the types of stones that are jewels, and S representing the stones you have.  Each character in S is a type of stone you have.  You want to know how many of the stones you have are also jewels. The letters in J are…
You're given strings J representing the types of stones that are jewels, and S representing the stones you have.  Each character in S is a type of stone you have.  You want to know how many of the stones you have are also jewels. The letters in J are…
You're given strings J representing the types of stones that are jewels, and S representing the stones you have.  Each character in Sis a type of stone you have.  You want to know how many of the stones you have are also jewels. The letters in J are…
描述 给定字符串J代表是珠宝的石头类型,而S代表你拥有的石头.S中的每个字符都是你拥有的一个石头. 你想知道你的石头有多少是珠宝. J中的字母一定不同,J和S中的字符都是字母. 字母区分大小写,因此"a"和"A"是不同的类型. S和J由字母组成且长度最大为50. J中字符各不相同. 您在真实的面试中是否遇到过这个题? 样例 样例 1: 输入: J = "aA", S = "aAAbbbb" 输出: 3 样例 2: 输入: J…