Calculate the number of operations needed to make 1 st k elements equal to the kth element i . e . the 1 st window
opsNeeded = 0 NEW_LINE for i in range ( k ) : NEW_LINE INDENT opsNeeded += ar [ k - 1 ] - ar [ i ] NEW_LINE DEDENT