Clean Product Names — Where + Select + Distinct
Scenario: An admin exports product names. Names may contain extra spaces, mixed casing and symbols. Goal: produce a clean unique list. What to implement: - ProductCleaner.GetUniqueNames(List<string> rawNames) Rules: - Trim, remove empty - Convert to Title Case style (first letter uppercase, rest lowercase) for each word - Remove duplicate names (case-insensitive) - Preserve unicode/emoji ✅ Implement ONLY the TODO method.
using System; // Console
using System.Collections.Generic; // List
using System.Linq; // LINQ
namespace ItTechGenie.M1.Linq.Q1
{
public static class ProductCleaner
{
// ✅ TODO: Student must implement only this method
public static List<string> GetUniqueNames(List<string> rawNames)
{
// TODO:
// - validate list
// - trim and remove empty
// - normalize casing per word (Title Case)
// - distinct case-insensitive
throw new NotImplementedException();
}
}
internal class Program
{
static void Main()
{
var raw = new List<string> { " laptop stand ", " LAPTOP STAND ", " headphones; noise-cancel ", " ", " cable-α12 ✅ " };
var names = ProductCleaner.GetUniqueNames(raw);
Console.WriteLine("Clean Names:");
names.ForEach(Console.WriteLine);
}
}
}