Tap here to switch tabs
Problem
Submissions

Problem: Maximal Range That Each Element Is Maximum in It

Try to solve the Maximal Range That Each Element Is Maximum in It problem.

Statement

Given a 00 indexed integer array nums consisting of unique values.

For each index i, determine the length of the longest contiguous subarray where nums[i] is the maximum element.

Return an array ans of the same length, where ans[i] is the length of this maximal subarray for the element at index i.

Constraints:

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

  • 1≤1 \leq nums[i] ≤105\leq 10^5

  • All elements in nums are distinct.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximal Range That Each Element Is Maximum in It

Try to solve the Maximal Range That Each Element Is Maximum in It problem.

Statement

Given a 00 indexed integer array nums consisting of unique values.

For each index i, determine the length of the longest contiguous subarray where nums[i] is the maximum element.

Return an array ans of the same length, where ans[i] is the length of this maximal subarray for the element at index i.

Constraints:

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

  • 1≤1 \leq nums[i] ≤105\leq 10^5

  • All elements in nums are distinct.