Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Count Bowl Subarrays

XPChallenge Points: 20
levelLevel: Medium


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.

Example 1:

Input: nums = [4, 7, 2, 6, 3]

Output: 1

Example 2:

Input: nums = [6, 1, 2, 3, 5]

Output: 3

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result