Practice Maximize Subarray GCD Score
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
You are given an array of positive integers nums and an integer k. You may perform at most k operations. In each operation, you can choose one element in the array and double its value. Each element can be doubled at most once. The score of a contiguous subarray is defined as the product of its length and the greatest common divisor (GCD) of all its elements. Your task is to return the maximum score that can be achieved by selecting a contiguous subarray from the modified array.
Source: Maximize Subarray GCD Score on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
nums = [2,4], k = 1
8
# Example 2
nums = [3,5,7], k = 2
14
# Example 3
nums = [5,5,5], k = 1
15
Constraints
Related LeetCode Problems
Practice more problems similar to Maximize Subarray GCD Score.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.