C# 8.0:
int Count=0; // result
var Found = new Dictionary<int, int>();
for (int i = 0; i < A.Length; i++)
if (!Found.ContainsKey(A[i])) Found.Add(A[i], 1);
else { if (Found[A[i]]++ == 2) Count++; }
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
C# 8.0:
int Count=0; // result
var Found = new Dictionary<int, int>();
for (int i = 0; i < A.Length; i++)
if (!Found.ContainsKey(A[i])) Found.Add(A[i], 1);
else { if (Found[A[i]]++ == 2) Count++; }