-
Notifications
You must be signed in to change notification settings - Fork 14
Solution #73 - Jabez/Edited - 17/3/2025 #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Solution #73 - Jabez/Edited - 17/3/2025 #37
Conversation
What This Code Does: | ||
* Find zeros in the matrix | ||
|
||
* If a cell is 0, mark its row and column to be zero later. | ||
* Use the first row & column as markers | ||
|
||
* To track if first row and column have zeros we use firstrow and firstcol boolean variables | ||
|
||
* Instead of creating extra memory, the first row and column store which rows/columns should be zero. | ||
* Set the marked cells to zero | ||
|
||
* Go through the matrix and make elements 0 based on the markers. | ||
* Handle the first row and column separately | ||
|
||
If the first row/column originally had a 0, set the entire first row/column to 0. | ||
|
||
Imagine this matrix: | ||
|
||
|
||
1 2 3 | ||
4 0 6 | ||
7 8 9 | ||
|
||
After running the code, it becomes: | ||
|
||
1 0 3 | ||
0 0 0 | ||
7 0 9 | ||
The 0 at (1,1) caused its entire row and column to be zero. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem too clear. Could you try doing something like this? https://github.com/Dijkstra-Edu/LeetCode-Solutions/pull/16/files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also use the template File for your explanation: https://github.com/Dijkstra-Edu/LeetCode-Solutions/blob/master/Explanation-Template.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kindly utilize Markdown capabilities for the explanation file, and try to do it using this as a template.
Solution and explanation added