← All problemsSign in

3410. Maximize Subarray Sum After Removing All Occurrences of One Element

LeetCodeArrayHash TableDivide and ConquerDynamic ProgrammingSegment TreePrefix SumOpen on judge ↗

You are given an integer array nums. You can do the following operation on the array at most once: - Choose any integer x such that nums remains non-empty on removing all occurrences of x. - Remove all occurrences of x from the array. Return the maximum subarray sum across all possible resulting arrays. Example 1: Input: nums = [-3,2,-2,-1,3,-2,3] Output: 7 Explanation: We can have the

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start