Distinct
1 /// <summary> 2 /// Solution A 3 /// 100/100 4 /// </summary> 5 /// <param name="A"></param> 6 /// <returns></returns> 7 public static int solution(int[] A) 8 { 9 if (A.Length == 0) return 0; 10 int result = 1; 11 Array.Sort(A); 12 for (int i = 1; i < A.Length; i++) 13 { 14 if (A[i] != A[i - 1]) 15 result++; 16 } 17 return result; 18 } 19 20 /// <summary> 21 /// Solution B 22 /// 100/100 23 /// </summary> 24 /// <param name="A"></param> 25 /// <returns></returns> 26 public static int solution(int[] A) 27 { 28 HashSet<int> hs = new HashSet<int>(); 29 foreach (int num in A) 30 { 31 hs.Add(num); 32 } 33 return hs.Count; 34 }