Right will move in right direction and compare difference between itself and element right to it
right = i NEW_LINE while ( right + 1 <= n - 1 and abs ( arr [ right ] - arr [ right + 1 ] ) <= K ) : NEW_LINE INDENT right = right + 1 NEW_LINE tmp = tmp + 1 NEW_LINE DEDENT