Code of expand the pond is not working correctly


is my code id.
Please sir tell the mistake in the code.
why ans is not getting updated to the correct value…

@Adarshrajpandey It is because you are not sending the visited array by reference. Rather you are sending a copy of the visited array each time. Use & in front of the array to send it by reference.

code is not getting submitted

on clicking submitt button it is showing nothing

@Adarshrajpandey
3 mistakes

  1. You’re applying DFS at each empty cell, complexity becomes n^2 it should be n where n = r*c
  2. You sent bool visit array by copy, instead declare it as a global variable
  3. You are not resetting values to 0 after setting to 1 before DFS

See this link for code and instructions Expand the pond