← 返回 amazon 的题目列表Maximize Sum After Operations
类型:online_judge
You are given an integer array nums consisting of both positive and negative numbers and an integer impactFactor. You can select a contiguous subarray of nums and apply exactly one of the following operations: Multiply all elements in the subarray by impactFactor. Divide all elements in the subarray by impactFactor (using integer division). Your goal is to maximize the sum of the selected subarray after performing the optimal operation. Return the maximum possible sum of any subarray after applying one of the operations. Provide the implementation and test cases.
Example
Input
[-1, -2, 3, 4], 2