Skip to content

Commit d659dc7

Browse files
committed
Create README - LeetHub
1 parent 044fb69 commit d659dc7

File tree

1 file changed

+31
-0
lines changed
  • 1918-maximum-score-of-a-good-subarray

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<h2><a href="https://leetcode.com/problems/maximum-score-of-a-good-subarray">1918. Maximum Score of a Good Subarray</a></h2><h3>Hard</h3><hr><p>You are given an array of integers <code>nums</code> <strong>(0-indexed)</strong> and an integer <code>k</code>.</p>
2+
3+
<p>The <strong>score</strong> of a subarray <code>(i, j)</code> is defined as <code>min(nums[i], nums[i+1], ..., nums[j]) * (j - i + 1)</code>. A <strong>good</strong> subarray is a subarray where <code>i &lt;= k &lt;= j</code>.</p>
4+
5+
<p>Return <em>the maximum possible <strong>score</strong> of a <strong>good</strong> subarray.</em></p>
6+
7+
<p>&nbsp;</p>
8+
<p><strong class="example">Example 1:</strong></p>
9+
10+
<pre>
11+
<strong>Input:</strong> nums = [1,4,3,7,4,5], k = 3
12+
<strong>Output:</strong> 15
13+
<strong>Explanation:</strong> The optimal subarray is (1, 5) with a score of min(4,3,7,4,5) * (5-1+1) = 3 * 5 = 15.
14+
</pre>
15+
16+
<p><strong class="example">Example 2:</strong></p>
17+
18+
<pre>
19+
<strong>Input:</strong> nums = [5,5,4,5,4,1,1,1], k = 0
20+
<strong>Output:</strong> 20
21+
<strong>Explanation:</strong> The optimal subarray is (0, 4) with a score of min(5,5,4,5,4) * (4-0+1) = 4 * 5 = 20.
22+
</pre>
23+
24+
<p>&nbsp;</p>
25+
<p><strong>Constraints:</strong></p>
26+
27+
<ul>
28+
<li><code>1 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
29+
<li><code>1 &lt;= nums[i] &lt;= 2 * 10<sup>4</sup></code></li>
30+
<li><code>0 &lt;= k &lt; nums.length</code></li>
31+
</ul>

0 commit comments

Comments
 (0)