#3326

Minimum Division Operations to Make Array Non Decreasing

expert · 1140 · lc medium +32 · 29.1% accepted · 136 likes · top 6%

Description

You are given an integer array nums.

A positive divisor of a natural number x that is strictly less than x is called a proper divisor of x. For example, 2 is a proper divisor of 4, but 6 is not a proper divisor of 6.

You may perform any number of operations on nums. In each operation, pick one element and divide it by its greatest proper divisor.

Return the minimum number of operations needed to make the array non-decreasing. If it is impossible, return -1.

Code

1
2
3