2789. Largest Element in an Array after Merge Operations
You are given a 0-indexed array
numsconsisting of positive integers.You can do the following operation on the array any number of times:
- Choose an integer
isuch that0 <= i < nums.length - 1andnums[i] <= nums[i + 1]. Replace the elementnums[i + 1]withnums[i] + nums[i + 1]and delete the elementnums[i]from the array.Return the value of the largest element that you can possibly obtain in the final array.
1 | class Solution { |