You are given an integer array nums.
Alice plays a game where she chooses an integer k > 1 and a contiguous subarray of nums defined by indices l and r where nums.length.
For every element nums[i] in the chosen subarray from index l to r:
If nums[i] is divisible by k, its value is added to Alice’s score.
If nums[i] is not divisible by k, its value is added to Bob’s score.
The score difference is defined as Alice’s score minus Bob’s score.
Alice wants to maximize the score difference. If there are multiple choices of k that achieve the maximum score difference, she chooses the minimum such k.
Return the value of
Constraints:
nums.length
nums[i]
You are given an integer array nums.
Alice plays a game where she chooses an integer k > 1 and a contiguous subarray of nums defined by indices l and r where nums.length.
For every element nums[i] in the chosen subarray from index l to r:
If nums[i] is divisible by k, its value is added to Alice’s score.
If nums[i] is not divisible by k, its value is added to Bob’s score.
The score difference is defined as Alice’s score minus Bob’s score.
Alice wants to maximize the score difference. If there are multiple choices of k that achieve the maximum score difference, she chooses the minimum such k.
Return the value of
Constraints:
nums.length
nums[i]