File tree Expand file tree Collapse file tree 1 file changed +14
-19
lines changed
solution/0300-0399/0350.Intersection of Two Arrays II Expand file tree Collapse file tree 1 file changed +14
-19
lines changed Original file line number Diff line number Diff line change @@ -214,35 +214,30 @@ class Solution {
214
214
```
215
215
216
216
### ** C#**
217
- ``` c#
217
+
218
+ ``` cs
218
219
public class Solution {
219
220
public int [] Intersect (int [] nums1 , int [] nums2 ) {
220
221
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 >();
222
223
List < int > result = new List <int >();
223
224
224
- foreach (int value in hs1 ){
225
- dict [value ] = 0 ;
225
+ foreach (int x in hs1 ) {
226
+ dict [x ] = 0 ;
226
227
}
227
228
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 ;
237
234
}
238
235
}
239
236
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 ;
246
241
}
247
242
}
248
243
You can’t perform that action at this time.
0 commit comments