Checking the down direction
if ( i + 1 < N && maze [ i + 1 ] [ j ] == 1 && visited [ i + 1 ] [ j ] ) { Node temp1 = new Node ( i + 1 , j ) ; visited [ i + 1 ] [ j ] = false ; s . push ( temp1 ) ; } } else if ( d == 3 ) {