Tap here to switch tabs
Problem
Submissions

Problem: Count Bowl Subarrays

Try to solve the Count Bowl Subarrays problem.

Statement

You are given an array of distinct integers nums.

A subarray nums[i...j] with a length of at least 33 (where j−i≥2j - i \ge 2) is called a bowl if both of its boundary elements are strictly greater than every element situated between them. That is, min⁡(\min( nums[i], nums[j] )>max⁡() > \max( nums[k] )) for all indices kk such that i<k<ji < k < j.

Return the total number of bowl subarrays in nums.

Constraints:

  • 3≤3 \le nums.length ≤105\le 10^5

  • 1≤1 \le nums[i] ≤109\le 10^9

  • nums consists of distinct elements.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count Bowl Subarrays

Try to solve the Count Bowl Subarrays problem.

Statement

You are given an array of distinct integers nums.

A subarray nums[i...j] with a length of at least 33 (where j−i≥2j - i \ge 2) is called a bowl if both of its boundary elements are strictly greater than every element situated between them. That is, min⁡(\min( nums[i], nums[j] )>max⁡() > \max( nums[k] )) for all indices kk such that i<k<ji < k < j.

Return the total number of bowl subarrays in nums.

Constraints:

  • 3≤3 \le nums.length ≤105\le 10^5

  • 1≤1 \le nums[i] ≤109\le 10^9

  • nums consists of distinct elements.