Minimum Cost to Equalize Array with Prefix Additions

Given an integer array arr. In one operation you may choose a prefix of length k (1 ≤ k ≤ n) and add an integer x (positive or negative) to every element in that prefix. The cost of the operat...

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Standard Input
Execution Result: