LeetCode 1551. Minimum Operations to Make Array Equal | Python

Pubblicato il: 06 aprile 2021
sul canale di: Lea's coding
76
1

April LeetCoding Challenge 2021
Medium
https://leetcode.com/problems/minimum...
___________________________________________________________________________
You have an array arr of length n where arr[i] = (2 * i) + 1 for all valid values of i.

In one operation, you can select two indices x and y where x, y in [0, n) and subtract 1 from arr[x] and add 1 to arr[y]. The goal is to make all the elements of the array equal. It is guaranteed that all the elements of the array can be made equal using some operations.

Given an integer n, the length of the array. Return the minimum number of operations needed to make all the elements of arr equal.

Example 1: Input: n = 3 Output: 2
Example 2: Input: n = 6 Output: 9
___________________________________________________________________________

#LeetCode #AprilLeetCodingChallenge2021 #Python #1551


In questa pagina del sito puoi guardare il video online LeetCode 1551. Minimum Operations to Make Array Equal | Python della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Lea's coding 06 aprile 2021, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 76 volte e gli è piaciuto 1 spettatori. Buona visione!