Skip to content

Complete DFS1#1405

Open
viveksharma180 wants to merge 1 commit intosuper30admin:masterfrom
viveksharma180:master
Open

Complete DFS1#1405
viveksharma180 wants to merge 1 commit intosuper30admin:masterfrom
viveksharma180:master

Conversation

@viveksharma180
Copy link
Copy Markdown

No description provided.

@super30admin
Copy link
Copy Markdown
Owner

Your solutions for flood fill are correct and efficient. Both BFS and DFS approaches are well-implemented.

Strengths:

  • You correctly handle the base case where the new color is the same as the original color.
  • You use appropriate data structures (deque for BFS) and recursion for DFS.
  • The code is clean and easy to understand.

Areas for improvement:

  • In the BFS solution, you can change while len(q): to while q: for better readability.
  • Consider moving the import statement for deque to the top of the file to avoid importing inside the function (though it's not a big issue).
  • For the DFS solution, note that recursion might lead to stack overflow for very large images (but the problem constraints are small, so it's acceptable).

Overall, both solutions are excellent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants