Leetcode(771)之宝石与石头
2020-01-04 18:11
1156 查看
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>>
题目描述:
解题思路:
其实就是考验知不知道hashset。
代码:
public int NumJewelsInStones(string J, string S) { int count = 0; HashSet<char> gems = new HashSet<char>(); foreach (char c in J) { gems.Add(c); } foreach (char c in S) { if (gems.Contains(c)) count++; } return count; }
相关文章推荐
- LeetCode每日刷题Day1--- 771 宝石与石头
- leetcode771.宝石与石头
- LeetCode 题库 全 JAVA 解题---771.宝石与石头
- Leetcode刷题1-771.宝石与石头(C++)
- Leetcode771.宝石与石头(python)
- LeetCode-771: 宝石与石头
- LeetCode编程771:宝石与石头
- Leetcode771宝石与石头
- Leetcode 771.宝石与石头
- (Python)LeetCode刷题笔记——771、宝石与石头
- LeetCode 刷题(python)之 宝石与石头
- leetcode题解——771. 宝石与石头
- Leetcode 771. 宝石与石头
- LeetCode 第771题 宝石与石头/Jawels and Stones
- leetcode初级算法 —— 1.2 宝石与石头 C++
- LeetCode宝石与石头(C语言)
- LeetCode 771. 宝石与石头
- Leetcode:宝石与石头
- 【LeetCode】宝石与石头
- 771.宝石与石头