Pushing the adjacent nodes i . e . indices reachable from the current index
if ( i + arr [ i ] < n ) : NEW_LINE INDENT q . append ( i + arr [ i ] ) NEW_LINE DEDENT if ( i - arr [ i ] >= 0 ) : NEW_LINE INDENT q . append ( i - arr [ i ] ) NEW_LINE DEDENT depth += 1 NEW_LINE return - 1 NEW_LINE