Tap here to switch tabs
Problem
Submissions

Problem: Count Subarrays Where Boundary Elements Are Maximum

Try to solve the Count Subarrays Where Boundary Elements Are Maximum problem.

Statement

You are given an array of positive integers nums.

Return the total number of subarrays where both the first and the last element are equal to the largest element in that subarray.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

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

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count Subarrays Where Boundary Elements Are Maximum

Try to solve the Count Subarrays Where Boundary Elements Are Maximum problem.

Statement

You are given an array of positive integers nums.

Return the total number of subarrays where both the first and the last element are equal to the largest element in that subarray.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

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