Store unique numbers in HashSet.
Ready — edit the code above and click Run.
using System;
class Program
{
static void Main()
{
using System.Collections.Generic;
var set = new HashSet<int> { 1, 2, 2, 3 };
Console.WriteLine(set.Count);
}
}
Try solving on your own first, then reveal the official answer.
HashSet enforces uniqueness automatically.