|
1 | 1 | """ |
2 | 2 | You are given an array nums of n positive integers. |
3 | 3 |
|
4 | | -You can perform two types of operations on any element of the array any number of times: |
| 4 | +You can perform two types of operations on any |
| 5 | +element of the array any number of times: |
5 | 6 |
|
6 | 7 | If the element is even, divide it by 2. |
7 | | -For example, if the array is [1,2,3,4], then you can do this operation on the last element, and the array will be [1,2,3,2]. |
| 8 | +For example, if the array is [1,2,3,4], then you can do this operation |
| 9 | +on the last element, and the array will be [1,2,3,2]. |
8 | 10 | If the element is odd, multiply it by 2. |
9 | | -For example, if the array is [1,2,3,4], then you can do this operation on the first element, and the array will be [2,2,3,4]. |
10 | | -The deviation of the array is the maximum difference between any two elements in the array. |
| 11 | +For example, if the array is [1,2,3,4], then you can do this operation |
| 12 | +on the first element, and the array will be [2,2,3,4]. |
| 13 | +The deviation of the array is the maximum difference between |
| 14 | +any two elements in the array. |
11 | 15 |
|
12 | | -Return the minimum deviation the array can have after performing some number of operations. |
| 16 | +Return the minimum deviation the array can have after performing |
| 17 | +some number of operations. |
13 | 18 | """ |
14 | 19 |
|
15 | 20 | from heapq import heapify, heappop, heappush |
16 | | - |
| 21 | + |
17 | 22 |
|
18 | 23 | class Solution: |
19 | 24 | def minimum_deviation(self, nums) -> int: |
|
0 commit comments