Find Subarrays With Maximum Boundary Elements
Find number of subarrays where boundary elements are max in nums, return count. Example: [1,4,3,3,2] has 6 such subarrays.
3113. Find the Number of Subarrays Where Boundary Elements Are Maximum Hard You are given an array of positive integers nums. Return the number of subarrays1 of nums, where the first and the last elements of the subarray are equal to the largest element in the subarray. Example 1: Input: nums = [1,4,3,3,2] Output: 6 Explanation: There are 6 subarrays which have the first and the last elements equal to the largest element of the subarray: subarray [1,4,3,3,2], with its largest element 1. The first element is 1 and the last element is also 1. subarray [1,4,3,3,2], with its largest element 4....
