You are given an integer array nums.
An array is called beautiful if for every index i > 0, the value at nums[i] is divisible by nums[i - 1].
In one operation, you may increment any element nums[i] (with i > 0) by 1.
Return the minimum number of operations required to make the array beautiful.
Example 1:
Input: nums = [3,7,9]
Output: 2
Explanation:
Applying the operation twice on nums[1] makes the array beautiful: [3,9,9]
Example 2:
Input: nums = [1,1,1]
Output: 0
Explanation:
The given array is already beautiful.
Example 3:
Input: nums = [4]
Output: 0
Explanation:
The array has only one element, so it's already beautiful.
Constraints:
1 <= nums.length <= 1001 <= nums[i] <= 50i, compute dp[i][val] where dp[i][val] is the minimum number of increments needed to make position i equal to val.i with those for index i - 1.[3,7,9]
[1,1,1]
[4]