LeetCode 1551. Minimum Operations to Make Array Equal | Python

Publicado el: 06 abril 2021
en el canal de: 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


En esta página del sitio puede ver el video en línea LeetCode 1551. Minimum Operations to Make Array Equal | Python de Duración hora minuto segunda en buena calidad , que subió el usuario Lea's coding 06 abril 2021, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 76 veces y le gustó 1 a los espectadores. Disfruta viendo!