Skip to content

Commit 71d932c

Browse files
committed
Add Jewels and Stones
1 parent 60bfec4 commit 71d932c

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

LeetCode/771-JewelsAndStones.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//Problem: https://leetcode.com/problems/jewels-and-stones/
2+
using System.Collections.Generic;
3+
4+
namespace LeetCode {
5+
public partial class Solution {
6+
public int NumJewelsInStones(string jewels, string stones) {
7+
var hashSet = new HashSet<char>(jewels);
8+
int count = 0;
9+
for(int i= 0; i < stones.Length; i++) {
10+
if(hashSet.Contains(stones[i])) {
11+
count++;
12+
}
13+
}
14+
15+
return count;
16+
}
17+
}
18+
}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ LeetCode C# solutions
77
|**344**| **[Reverse String](https://leetcode.com/problems/reverse-string/)** | **[C#](https://github.com/ocimen/leetcode/blob/main/LeetCode/344-ReverseString.cs)** | **Easy** |
88
|**509**| **[Fibonacci Number](https://leetcode.com/problems/fibonacci-number/)** | **[C#](https://github.com/ocimen/leetcode/blob/main/LeetCode/509-FibonacciNumber.cs)** | **Easy** |
99
|**682**| **[Baseball Game](https://leetcode.com/problems/baseball-game/)** | **[C#](https://github.com/ocimen/leetcode/blob/main/LeetCode/682-BaseballGame.cs)** | **Easy** |
10+
|**771**| **[Jewels and Stones](https://leetcode.com/problems/jewels-and-stones/)** | **[C#](https://github.com/ocimen/leetcode/blob/main/LeetCode/771-JewelsAndStones.cs)** | **Easy** |
1011
|**933**| **[Number of Recent Calls](https://leetcode.com/problems/number-of-recent-calls/)** | **[C#](https://github.com/ocimen/leetcode/blob/main/LeetCode/933-NumberofRecentCalls.cs)** | **Easy** |
1112
|**1108**| **[Defanging an IP Address](https://leetcode.com/problems/defanging-an-ip-address/)** | **[C#](https://github.com/ocimen/leetcode/blob/main/LeetCode/1108-DefangingAnIPAddress.cs)** | **Easy** |
1213
|**1290**| **[Convert Binary Number in a Linked List to Integer](https://leetcode.com/problems/convert-binary-number-in-a-linked-list-to-integer/)** | **[C#](https://github.com/ocimen/leetcode/blob/main/LeetCode/1290-ConvertBinaryNumberLinkedListInteger.cs)** | **Easy** |

0 commit comments

Comments
 (0)