how is the output 1 for a=1,b=1, it should be 0, as there is no path?
How is the output 1 for a=1,b=1, it should be 0, as there is no path?
The start and the end positions are the same. So, a path does exist which has just one position ( = (1,1) ).
Anshuman Singh I still disagree. There cannot be a path if initial and final points are same.
Suyash Ahuja Do you think looking at a formal definition of a path would help ?
Path in my understanding is a sequence of vertices ( in this case grid cells ) where each neighbor in the sequence is connected directly. In this case, the sequence just has one vertex.