1799. Maximize Score After N Operations
https://leetcode.com/problems/maximize-score-after-n-operations
Description
You are given nums
, an array of positive integers of size 2 * n
. You must perform n
operations on this array.
In the ith
operation (1-indexed), you will:
Choose two elements,
x
andy
.Receive a score of
i * gcd(x, y)
.Remove
x
andy
fromnums
.
Return the maximum score you can receive after performing n
operations.
The function gcd(x, y)
is the greatest common divisor of x
and y
.
Example 1:
Example 2:
Example 3:
Constraints:
1 <= n <= 7
nums.length == 2 * n
1 <= nums[i] <= 106
ac
Previous1798. Maximum Number of Consecutive Values You Can MakeNext1800. Maximum Ascending Subarray Sum
Last updated