#3676

Count Bowl Subarrays

specialist · 905 · lc medium +31 · 48% accepted · 183 likes · top 33%

Description

An integer array nums with distinct elements is given. A bowl subarray nums[l..r] has length at least 3 and satisfies min(nums[l], nums[r]) > max(nums[l+1..r-1]) (both endpoints are larger than all interior elements). Count and return the number of bowl subarrays.

Code

1
2
3