You are given an integer array nums.
In one operation, you perform the following steps:
Find an adjacent pair of elements in nums with the minimum sum. If there are multiple such adjacent pairs, choose the leftmost one.
Replace the two chosen elements with a single element equal to their sum.
Repeat this operation until nums is sorted in nondecreasing order.
Return the total number of operations required to make nums sorted in nondecreasing order.
Constraints:
nums.length
nums[i]
You are given an integer array nums.
In one operation, you perform the following steps:
Find an adjacent pair of elements in nums with the minimum sum. If there are multiple such adjacent pairs, choose the leftmost one.
Replace the two chosen elements with a single element equal to their sum.
Repeat this operation until nums is sorted in nondecreasing order.
Return the total number of operations required to make nums sorted in nondecreasing order.
Constraints:
nums.length
nums[i]