Tap here to switch tabs
Problem
Submissions

Problem: Maximum Subarray Sum After One Operation

Maximum Subarray Sum After One Operation asks you to square exactly one array value, then return the largest sum among all nonempty contiguous subarrays.

Statement

You are given an integer array nums. You must perform an operation exactly once by choosing an index i and replacing nums[i] with nums[i] * nums[i].

Return the maximum possible sum of a contiguous non empty subarray after applying this operation.

Note: A subarray is a contiguous sequence of elements within an array.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • −104≤-10^4 \leq nums[i] ≤104\leq 10^4

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Subarray Sum After One Operation

Maximum Subarray Sum After One Operation asks you to square exactly one array value, then return the largest sum among all nonempty contiguous subarrays.

Statement

You are given an integer array nums. You must perform an operation exactly once by choosing an index i and replacing nums[i] with nums[i] * nums[i].

Return the maximum possible sum of a contiguous non empty subarray after applying this operation.

Note: A subarray is a contiguous sequence of elements within an array.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • −104≤-10^4 \leq nums[i] ≤104\leq 10^4