You are given an integer array nums.
In one operation, you may choose any element nums[i] and perform one of the following:
nums[i] by an integer k, where k >= 2.nums[i] by an integer k, where 2 <= k < nums[i], provided that nums[i] is divisible by k.Return the minimum number of operations required to make all elements of nums equal.
Example 1:
Input: nums = [6,12,8]
Output: 3
Explanation:
We can perform following operates to make all numbers to 6:
nums[1] = 12 by 2 to get 6.nums[2] = 8 by 4 to get 2.nums[2] = 2 by 3 to get 6.Example 2:
Input: nums = [5,15,20]
Output: 2
Explanation:
We can perform following operates to make all numbers to 5:
nums[1] = 15 by 3 to get 5.nums[2] = 20 by 4 to get 5.Example 3:
Input: nums = [7,7,7]
Output: 0
Explanation:
All elements are already equal, so no operations are needed.
Constraints:
1 <= nums.length <= 1051 <= nums[i] <= 109Loading editor...
No test cases available.