3410. Maximize Subarray Sum After Removing All Occurrences of One Element
You are given an integer array
nums
.You can do the following operation on the array at most once:
- Choose any integer
x
such thatnums
remains non-empty on removing all occurrences ofx
.- Remove all occurrences of
x
from the array.Return the maximum subarray sum across all possible resulting arrays.
A subarray is a contiguous non-empty sequence of elements within an array.
c++
1 | struct Seg { |