#3507
Minimum Pair Removal to Sort Array I
pupil · 345 · lc easy +22 · 65.3% accepted · 487 likes · top 70%
Description
Starting from array nums, repeatedly merge the leftmost minimum-sum adjacent pair (replacing the two elements with their sum) until the array is non-decreasing.
Return the number of merge operations required.
Code
1
2
3