This problem is easily solveable if you simplify it into groups of the same number. For instance, in your example {1,2,2,3} the groups are: 1 with 1 times it appears, 2 with 2 appearances, and 3 with 1 appearance. For {1,4,1,1}, the groups are 1 with 3 count, and 4 with 1 count. This is true no matter what the order of the array, right? If it was {1,1,1,4} it would still be 1 with 3 count, and 4 with 1 count.

Now, assuming that 4-of-a-kind is also considered a win, the the array is {X, X, X, X} with X being any number. In this case, there is only one group, X, with a count of 4. In the minimum win case, {X, X, X, Y} (and all other permutations of it), there is will always be an X with a count of 3, and a Y with a count of 1. Both win conditions can be generalized like this: One group will always have a count of 3 or more and there will always be 2 groups or less.

You can pull off this concept of groups with a System.Collections.Generic.Dictionary. With the dictionary, the element’s key would be a number in your array, and the value associated would represent how many times that number appears in your array.

The code would go something like this: You would loop through each element in the top array, and if it doesn’t already exist in the dictionary, add it to the dictionary with count of 1. If the number already exists in the dictionary, just increase the value by 1.

After looping through the array, it would then be a simple loop through the dictionary to see if there are any elements who’s values are greater or equal to 3.

For the array {1,4,1,1}, the dictionary’s elements would be {(1,3), (4,1)}. If you do not know how to use Dictionary, there are plenty of resources out there, including the this one and this one.