Search
⌘K
Get Premium
Leetcode 2448. Minimum Cost to Make Array Equal
Given arrays nums and per-unit costs, choose a target value t to minimize the total cost sum(cost[i] * |nums[i] - t|); this is a convex piecewise-linear objective whose optimum is the weighted median of nums (can be found via sorting and accumulating costs).
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
All Regions
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.