I started working on this problem a while ago, and ran into the issue of keeping track of unique pairs of cows that are valid for two-cow teams winning.

What’s the most efficient way to keep track of the pairs of cows? I’m currently using Java.

I’ve run into this problem in a few other problems, and have done some pretty inconvenient solutions (2d arrays), so I’m just wondering if there’s a better way to do it.