Function to find whether the move is valid or not
bool isValid ( int grid [ ] [ col ] , int i , int j ) { if ( i < 0 j < 0 j > = col i > = row grid [ i ] [ j ] visited [ i ] [ j ] ) return false ; return true ; }