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.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
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
I know Count() maybe adds unneeded complexity and it may not be a one pass.
I'm looking for feedback here.