C++ solution without using 2D-Hash.
IntuitionInstead of using a vector of vectors (vector<vector<int>>), you could store the amount of balls in a single number. Each digit in the number could hold
# Intuition
Instead of using a vector of vectors (`vector<vector<int>>`), you could store the amount of balls in a single number. Each digit in the number could hold the amount of balls. For example, the ones digit could hold balls of color 0, tens holds color 1 balls, and so on. 

# Approach
This approach lies on the fact that the constraints are small, and the amount of players is at most 9.
Use a vector to hold the hash values of each player from 0-9. The maximum value of `unsigned int` is 4,294,967,295, so you will have to use an `unsigned long` just in case there are more than 4 balls of color 10. 
The loop goes through each pair of values, calculates the 10^*color* for current ball, and adds it to the current player's hash value. If the amount of balls of the current ball's color is equal to the current player's number, then they win (adding the current ball will make it greater than). Otherwise, the ball's value is added to the hash value of that player. It is an if-else statement just in case the amount of balls of a single color is more than 9, which will overflow to the next digit in the hash.
I used a bitset to check off the players who win the game, because the player wins the game when they collect enough balls even if they collect more. If you use a counter, then the loop might encounter a situation when a player collects a ball even though they won the game already. If the amount of players is not known, then you could use a `vector<bool>` instead of the bitset.

# Complexity
- Time complexity:
**O(p)**, where *p* is the number of turns in *pick*, if the amount of ball colors is fixed to 10. The loop goes through each pair of values only once, and access to the hash is constant. I believe the `pow` function has a time complexity of **O(log e)**, where *e* is the exponent. The maximum exponent is 10, so the complexity of `pow` becomes constant;

- Space complexity:
**O(n)**, where *n* is the amount of players and the amount of ball colors is fixed. If the amount of ball colors exceeds the amount of digits available in the data type, then this approach cannot be done.

# Code
```cpp []
class Solution {
public:
    int winningPlayerCount(int n, vector<vector<int>>& pick) {
        vector<unsigned long> players(n);
        bitset<10> win;
        unsigned long e;
        for (auto& p: pick) {
            e = pow(10, p[1]);
            if (players[p[0]] / e % 10 == p[0]) win.set(p[0]); 
            else players[p[0]] += e;
        }
        return win.count();
    }
};
```
['C++']