Remove duplicates from a list preserving order using HashSet.
Toolliyo Coach
Progressive help: Nudge → Guide → Approach. Full solution stays behind the Solution tab.
Editor is open — no login wall to practice.
| Test | Status | Details |
|---|
Ready — edit the code above and click Run or Submit.
using System;
using System.Collections.Generic;
class Program {
static void Main() {
var input = new List<int> { 1, 2, 2, 3, 1, 4 };
var seen = new HashSet<int>();
var unique = new List<int>();
foreach (var x in input)
if (seen.Add(x)) unique.Add(x);
Console.WriteLine(string.Join(",", unique));
}
}
Prefer Coach (Nudge → Guide → Approach) before revealing. No forced signup.
HashSet.Add returns false if item exists—efficient dedupe.
Sign in to save and review your submission history. You can still Run code on the Editor tab as a guest.
Sign inInstall Toolliyo like an app Free
Home-screen access to tutorials, coding practice & career tools — no app store needed.
On iPhone/iPad: tap Share then Add to Home Screen.