My code not working - dfs c++

sir can you please see my code to the problem :https://leetcode.com/problems/rotting-oranges
solution:https://ide.codingblocks.com/s/305861 the value of c is not coming correct.

please reply sir!!!

Your problem is, see that you are considering that at any point there is only one rotten orange
you go to that orange and do dfs
but if there are multiple rotten oranges, all of them will work at once
example
consider
2 1 0
1 0 0
0 2 1
according to your algo, answer will be 2
but actually both oranges at 0,0 and 2,1 will rot adjacent oranges at once and the answer should be 1
so at each instance when u call dfs, u must retain only the maximum value

fixes for this:
save all the rotten oranges at once, and run the algo in BFS manner
second store max after each call
but there is one fault in second also
consider
2 1 1 2
in the second method, it will again give 2
because first call pertains to 2 steps and so does the second call but in reality
orange at 0,0 will rot orange at 0,1 and orange at 0,3 will rot orange at 0,2 and hence done in 1 second
plus add a check for -1 also, which was missing from your code
I hope this helps

thanks sir got your point will work on it