If the movement is towards right , then we move right . The start variable and mark that position as visited if not visited previously else we break out
else { if ( mark [ start ] == 0 ) { mark [ start ] = 1 ; start += a [ start ] ; }