Number of Islands Edge test case failing

I used dfs to process the grid but edge test case 3 is failing. can someone give me some hint?

Hint for edge test cases:

  • Does your code handle all non-negative inputs?
  • Does your code handle an all 0 or all 1 matrix?

Closing this topic as there is no response since last 12 hours. Please feel free to create a new topic and post this question as a reference link in the description of the new topic.