[Codeforces] CodeTON Round 8 (Div. 1 + Div. 2, Rated, Prizes!) C2. Bessie`s Birthday Cake (Hard Version)Read more
[Codeforces] Round 933 (Div. 3) F. Rudolf and ImbalanceRead more
[Codeforces] Round 933 (Div. 3) E. Rudolf and k BridgesRead more
[Codeforces] Round 930 (Div. 1) A. Bitwise Operation WizardRead more
[Codeforces] Round 932 (Div. 2) D. Exam in MACRead more
[Codeforces] Round 932 (Div. 2) C. Messenger in MACRead more
[Codeforces] Round 931 (Div. 2) C. Find a MineRead more
[Codeforces] Round 927 (Div. 3) E. Final CountdownRead more
[Codeforces] Round 925 (Div. 3) F. Chat ScreenshotsRead more
[LeetCode] Minimum Cost to Equalize Array

3139. Minimum Cost to Equalize Array

You are given an integer array nums and two integers cost1 and cost2. You are allowed to perform either of the following operations any number of times:

  • Choose an index i from nums and increase nums[i] by 1 for a cost of cost1.
  • Choose two different indices i, j, from nums and increase nums[i] and nums[j] by 1 for a cost of cost2.

Return the minimum cost required to make all elements in the array equal*.*

Since the answer may be very large, return it modulo 109 + 7.

Read more