mirror of
https://github.com/Manoj-HV30/dsa-competitive-programming.git
synced 2026-05-16 19:35:22 +00:00
add codeforces solutions folder
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
class Solution{
|
||||
public:
|
||||
int numSpecial(vector<vector<int>> &mat){
|
||||
int ans = 0;
|
||||
int r = mat.size();
|
||||
int c = mat[0].size();
|
||||
for(int row=0;row<r;row++){
|
||||
for(int col = 0;col<c;col++){
|
||||
if(mat[row][col]==0) continue;
|
||||
bool good = true;
|
||||
for(int m = 0;m<r;m++){
|
||||
if(m!=row && mat[m][col] == 1){
|
||||
good = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for(int n = 0;n<c;n++){
|
||||
if(n!=col && mat[row][n] == 1){
|
||||
good = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(good) ans++;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
return ans;
|
||||
}
|
||||
};
|
||||
|
||||
//TC : o(r.c(r+c)) SC: o(1)
|
||||
Reference in New Issue
Block a user