Add implementation for leetcode problems 733, 542#1408
Add implementation for leetcode problems 733, 542#1408rishigoswamy wants to merge 1 commit intosuper30admin:masterfrom
Conversation
Flood Fill the image (leetcode_542.py)It appears that you have submitted a solution for the "01 Matrix" problem (LeetCode 542) instead of the "Flood Fill" problem. The "Flood Fill" problem requires you to start from a specific pixel (sr, sc) and fill all connected pixels of the same color with a new color. For the "Flood Fill" problem, you should use a BFS or DFS approach starting from (sr, sc). Here are the key steps:
Your current solution for "01 Matrix" uses a multi-source BFS starting from all zeros, which is not applicable here. Please implement the correct algorithm for "Flood Fill". VERDICT: NEEDS_IMPROVEMENT Nearest zero (leetcode_733.py)Your solution demonstrates a good understanding of BFS and flood fill, but it is for the wrong problem. Please carefully read the problem statement again. The problem is "Nearest Zero", which requires you to compute the distance from each cell to the nearest zero in the matrix. For the correct problem, you should consider the following approach:
You have the right idea with BFS, but the application is incorrect. Also, note that the problem constraints require an efficient solution since the matrix can be large. Here is a hint: Instead of starting from a single point (like in flood fill), you need to start from all zeros at once. This is known as multi-source BFS. VERDICT: NEEDS_IMPROVEMENT |
No description provided.