Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PROBLEM] 1793. Maximum Score of a Good Subarray #164

Open
godkingjay opened this issue Oct 22, 2023 · 1 comment · Fixed by #166
Open

[PROBLEM] 1793. Maximum Score of a Good Subarray #164

godkingjay opened this issue Oct 22, 2023 · 1 comment · Fixed by #166
Assignees
Labels
dificulty: hard Hard difficulty problem. hacktoberfest Hacktoberfest issue. problem LeetCode problem.

Comments

@godkingjay
Copy link
Owner

Difficulty

Hard

Problem Description

You are given an array of integers nums (0-indexed) and an integer k.

The score of a subarray (i, j) is defined as min(nums[i], nums[i+1], ..., nums[j]) * (j - i + 1). A good subarray is a subarray where i <= k <= j.

Return the maximum possible score of a good subarray.

Example 1:

Input: nums = [1,4,3,7,4,5], k = 3
Output: 15
Explanation: The optimal subarray is (1, 5) with a score of min(4,3,7,4,5) * (5-1+1) = 3 * 5 = 15. 

Example 2:

Input: nums = [5,5,4,5,4,1,1,1], k = 0
Output: 20
Explanation: The optimal subarray is (0, 4) with a score of min(5,5,4,5,4) * (4-0+1) = 4 * 5 = 20.

Constraints:

  • 1 <= nums.length <= 105
  • 1 <= nums[i] <= 2 * 104
  • 0 <= k < nums.length

Link

https://leetcode.com/problems/maximum-score-of-a-good-subarray/

@godkingjay godkingjay added hacktoberfest Hacktoberfest issue. problem LeetCode problem. dificulty: hard Hard difficulty problem. labels Oct 22, 2023
@12345rams
Copy link
Contributor

assign me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dificulty: hard Hard difficulty problem. hacktoberfest Hacktoberfest issue. problem LeetCode problem.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants