└── 2133. Check if Every Row and Column Contains All Numbers.cpp /2133. Check if Every Row and Column Contains All Numbers.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | bool checkValid(vector>& matrix) { 4 | int n = matrix.size(); 5 | for (int i = 0; i < n; i++) { 6 | unordered_map mp; 7 | for (int j = 0; j < n; j++) { 8 | mp[matrix[i][j]]++; 9 | } 10 | for (int j = 1; j <= n; j++) { 11 | if (mp[j] != 1) { 12 | return false; 13 | } 14 | } 15 | } 16 | for (int i = 0; i < n; i++) { 17 | unordered_map mp; 18 | for (int j = 0; j < n; j++) { 19 | mp[matrix[j][i]]++; 20 | } 21 | for (int j = 1; j <= n; j++) { 22 | if (mp[j] != 1) { 23 | return false; 24 | } 25 | } 26 | } 27 | 28 | return true; 29 | } 30 | }; 31 | --------------------------------------------------------------------------------