#3113
Find the Number of Subarrays Where Boundary Elements Are Maximum
hard · 32.9% accepted · 262 likes · top 10%
array · binary search · stack · monotonic stack
Description
You are given an array of positive integers nums.
Return the number of subarrays of nums, where the first and the last elements of the subarray are equal to the largest element in the subarray.
Solution