Practice Minimize Deviation in Array
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Starting with positive integers nums, repeatedly select any element. An even value may be divided by 2; an odd value may be multiplied by 2. Return the smallest possible difference between the largest and smallest array values after any number of these operations.
Source: Minimize Deviation in Array on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
nums = [1,2,3,4]
Output
1
# Example 2
Input
nums = [4,1,5,20,3]
Output
3
# Example 3
Input
nums = [2,10,8]
Output
3
Constraints
n == nums.length
2 <= n <= 5 * 10^4
1 <= nums[i] <= 10^9
Related LeetCode Problems
Practice more problems similar to Minimize Deviation in Array.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.