Ezvor

3874. Valid Subarrays With Exactly One Peak

MediumArray Preparing judge… LeetCode
ArrayMath

Hints

Hint 1
Gather peak indices and find the boundaries where each is the only peak.
Hint 2
Calculate how far the left and right endpoints for each peak can extend under the constraints.
Hint 3
Sum the product of the possible left and right endpoints for each peak.