Practice Maximize Score After N Operations
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Hard#1799
LeetCode ProblemMaximize Score After N Operations
Problem Statement
nums contains 2n positive values. On operation i, numbered 1 through n, choose two remaining entries x and y, add i * gcd(x,y) to the score, and remove both entries. Return the greatest total score over all choices and operation orders.
Source: Maximize Score After N Operations on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
nums = [1,2]
Output
1
# Example 2
Input
nums = [3,4,6,8]
Output
11
# Example 3
Input
nums = [1,2,3,4,5,6]
Output
14
Constraints
1 <= n <= 7
nums.length == 2 * n
1 <= nums[i] <= 10^6
Related LeetCode Problems
Practice more problems similar to Maximize Score After N Operations.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.