Function to check whether the path exists
static boolean hasPath ( int maze [ ] [ ] , int sol [ ] [ ] , int N ) { for ( int i = 0 ; i < N ; i ++ ) for ( int j = 0 ; j < N ; j ++ ) sol [ i ] [ j ] = 0 ;