if above answer is yes then, why this sol not working??
Leetcode 2133
(https://leetcode.com/problems/check-if-every-row-and-column-contains-all-numbers/)
<code> unordered_map<int,int> mp;
int n=matrix.size();
for(int i=0; i<n; i++){
for(int j=0; j<n; j++){
mp[matrix[i][j]]++;
}
}
for (auto i = mp.begin(); i != mp.end(); i++)
if(i-> second!=n) return false;
return true;
</code>
<code> unordered_map<int,int> mp;
int n=matrix.size();
for(int i=0; i<n; i++){
for(int j=0; j<n; j++){
mp[matrix[i][j]]++;
}
}
for (auto i = mp.begin(); i != mp.end(); i++)
if(i-> second!=n) return false;
return true;
</code>
unordered_map<int,int> mp;
int n=matrix.size();
for(int i=0; i<n; i++){
for(int j=0; j<n; j++){
mp[matrix[i][j]]++;
}
}
for (auto i = mp.begin(); i != mp.end(); i++)
if(i-> second!=n) return false;
return true;
the above code should work
New contributor
Deepak Kumar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.