Skip to content

Commit 60a0fae

Browse files
authored
Update README_EN.md
1 parent 997c6ad commit 60a0fae

File tree

1 file changed

+14
-19
lines changed
  • solution/0300-0399/0350.Intersection of Two Arrays II

1 file changed

+14
-19
lines changed

solution/0300-0399/0350.Intersection of Two Arrays II/README_EN.md

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -214,35 +214,30 @@ class Solution {
214214
```
215215

216216
### **C#**
217-
```c#
217+
218+
```cs
218219
public class Solution {
219220
public int[] Intersect(int[] nums1, int[] nums2) {
220221
HashSet<int> hs1 = new HashSet<int>(nums1.Concat(nums2).ToArray());
221-
Dictionary<int,int> dict = new Dictionary<int,int>();
222+
Dictionary<int, int> dict = new Dictionary<int, int>();
222223
List<int> result = new List<int>();
223224

224-
foreach(int value in hs1){
225-
dict[value] = 0;
225+
foreach (int x in hs1) {
226+
dict[x] = 0;
226227
}
227228

228-
foreach(int value in nums1)
229-
{
230-
if(dict.ContainsKey(value))
231-
{
232-
dict[value]+=1;
233-
}
234-
else
235-
{
236-
dict[value] = 1;
229+
foreach (int x in nums1) {
230+
if (dict.ContainsKey(x)) {
231+
dict[x] += 1;
232+
} else {
233+
dict[x] = 1;
237234
}
238235
}
239236

240-
foreach(int value in nums2)
241-
{
242-
if(dict[value] > 0)
243-
{
244-
result.Add(value);
245-
dict[value] -=1;
237+
foreach (int x in nums2) {
238+
if (dict[x] > 0) {
239+
result.Add(x);
240+
dict[x] -=1;
246241
}
247242
}
248243

0 commit comments

Comments
 (0)