Coverage of all Zeros in a Binary Matrix | gfg potd | 26-06-24 | GFG Problem of the day
Вставка
- Опубліковано 30 вер 2024
- Geeks for Geeks Problem of the Day(POTD) in C++ | Coverage of all Zeros in a Binary Matrix | Fully Explained🧠
Solution Code :
github.com/Ish...
IMPORTANCE OF DSA FOR PLACEMENT:
• Is DSA Still Important...
BEST FREE WEB DEVELOPMENT COURSE:
• Video
🌐 Connect with Me:
GitHub: github.com/Ish...
Linkedin: / ishansawhney
#GFG #POTD #geeksforgeeks #problemoftheday #c++
Bro teri level of understanding bohot acchi hai how you achieve this level of knowledge are you iitian of what
Thanks bro...no I'm not iitian
All this can be achieved by regular practice 😊
Nice 👍
Thanks 😊
int covverage(vector &matrix)
{
int r = matrix.size();
int c = matrix[0].size();
int sum = 0;
for (int i = 0; i < r; i++)
{
for (int j = 0; j < c; j++)
{
if (matrix[i][j] == 0)
{
if (j > 0 && matrix[i][j - 1] == 1) // left element
{
sum += 1;
}
if (i < r - 1 && matrix[i][j + 1] == 1) //right element
{
sum += 1;
}
if (i > 0 && matrix[i - 1][j] == 1) // upside element
{
sum += 1;
}
if (i < r - 1 && matrix[i + 1][j] == 1) // downside element
{
sum += 1;
}
}
}
return sum;
}
} bhai ye code chal to gaya but muje right side element and downside element mai i < r - 1 , j < c - 1 ye boundary cases ka logic samaj nahi aya can you help in this
Bhai ye code same mere Wale jaisa hai...video dekho yehi cheez smjha rkhi hai maine
class Solution {
public:
int findCoverage(vector& matrix) {
// Code here
int ans = 0;
int n = matrix.size();
int m = matrix[0].size();
for(int i = 0; i < n; i++){
for(int j = 0; j < m-1; j++){
ans+=matrix[i][j]^matrix[i][j+1];
}
}
for(int i = 0; i < m; i++){
for(int j = 0; j < n-1; j++){
ans+=matrix[j][i]^matrix[j+1][i];
}
}
return ans;
}
};
I have tried this approach and works correctly. Just basic XOR operation.
Awsm👏🏻
@@CodeGenius316 Thanks😃
Very helpful video! The explanation is clear and easy to understand. Great job!
Thanks 😊
Thanks for sharing explanation bro 💜
Welcome bro 😊