3830. Longest Alternating Subarray After Removing At Most One Element
You are given an integer array nums. A subarray nums[l..r] is alternating if one of the following holds: - nums[l] < nums[l + 1] > nums[l + 2] < nums[l + 3] > ... - nums[l] > nums[l + 1] < nums[l + 2] > nums[l + 3] < ... In other words, if we compare adjacent elements in the subarray, then the comparisons alternate between strictly greater and strictly smaller. You can remove at most one elem
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.
Sign in to chat with the tutor and save your progress.
Sign in to start