You are given an integer array nums containing distinct elements.
A subarray nums[l...r] of nums is called a bowl if it satisfies both of the following conditions:
1. The subarray has a length of at least 3 (i.e., r - l + 1 ≥ 3).
2. The minimum of its two end elements is strictly greater than the maximum of all elements in between, i.e.
min(nums[l],nums[r])>max(nums[l+1],…,nums[r−1])
Return the total number of bowl subarrays in nums.
Input: nums = [4, 7, 2, 6, 3]
Output: 1
Input: nums = [6, 1, 2, 3, 5]
Output: 3
Accepted:
Submission: