Function to find whether the move is valid or not
def isValid ( grid , i , j ) : NEW_LINE INDENT if ( i < 0 or j < 0 or j >= col or i >= row or grid [ i ] [ j ] or visited [ i ] [ j ] ) : NEW_LINE INDENT return False NEW_LINE DEDENT return True NEW_LINE DEDENT