Tap here to switch tabs
Problem
Submissions

Problem: Maximum Score of a Good Subarray

med
30 min
Try to solve the Maximum Score of a Good Subarray problem.

Statement

You are given an integer array nums (00 indexed) and an integer k.

The score of a subarray (i, j) is defined as min⁡(\min(nums[i], nums[i + 1], …\dots, nums[j])×(j−i+1)) \times (j - i + 1).

A subarray (i, j) is considered good if i≤k≤ji \leq k \leq j.

Return the maximum possible score of a good subarray.

Constraints:

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

  • 1≤1 \leq nums[i] ≤2×104\leq 2 \times 10^4

  • 0≤0 \leq k << nums.length

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Score of a Good Subarray

med
30 min
Try to solve the Maximum Score of a Good Subarray problem.

Statement

You are given an integer array nums (00 indexed) and an integer k.

The score of a subarray (i, j) is defined as min⁡(\min(nums[i], nums[i + 1], …\dots, nums[j])×(j−i+1)) \times (j - i + 1).

A subarray (i, j) is considered good if i≤k≤ji \leq k \leq j.

Return the maximum possible score of a good subarray.

Constraints:

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

  • 1≤1 \leq nums[i] ≤2×104\leq 2 \times 10^4

  • 0≤0 \leq k << nums.length