re: Daily Coding Problem #1 VIEW POST


Don't know if it suits the problem given the fact that it'll output true/false on each item in the HashSet but here's my take on the problem

static void SumExists(HashSet<int> values, int k)
   foreach (var item in values)
       Console.WriteLine(values.Count(x => x + item == k) > 0);

I know Count() maybe adds unneeded complexity and it may not be a one pass.
I'm looking for feedback here.

Code of Conduct Report abuse