# Leetcode 1793: Maximum Score of a Good Subarray

3 min readMar 21, 2021

--

In this problem, we are trying to optimize the “score” of “good subarrays defined this way:

You are given an array of integers

`nums`

(0-indexed)and an integer`k`

.The

scoreof a subarray`(i, j)`

is defined as`min(nums[i], nums[i+1], ..., nums[j]) * (j - i + 1)`

. Agoodsubarray is a subarray where`i <= k <= j`

.Return

the maximum possiblescoreof agoodsubarray.