Java 1ms beats 100%, populate 2-d matrix[][] with each player's ball counts
Intuition\n Describe your first thoughts on how to solve this problem. \nWe have to tally the balls for each player to check for winners.\n\n# Approach\n Descri
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nWe have to tally the balls for each player to check for winners.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nTransform the 2-d input array to a 2-d matrix where row = player and col = number of balls of each color.\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n$$O(n)$$ where n is the input array\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n$$O(n)$$\n\n# Code\n```java []\n\nclass Solution {\n\n    static final int NUM_COLORS = 11;\n\n    public int winningPlayerCount(int numPlayers, int[][] picks) {\n        int[][] matrix = new int[numPlayers][NUM_COLORS];\n\n        for (int[] p : picks) {\n            matrix[p[0]][p[1]]++;\n        }\n\n        int numWinners = 0; // what we\'ll return\n\n        for (int playerNum = 0; playerNum < numPlayers; playerNum++) {\n            for (int ballColor = 0; ballColor < NUM_COLORS; ballColor++) {\n                if (matrix[playerNum][ballColor] > playerNum) {\n                    numWinners++;\n                    break; // no need to check whether this player won for another ball color\n                }\n            }\n        }\n\n        return numWinners;\n    }\n}\n\n```
['Java']