6
var maximumScore = function (nums, k) {7
// iterate to the left to update the minimum value at each index9
for (let i = k - 1; i >= 0; i--) {10
min = Math.min(min, nums[i]);14
// iterate to the right to update the minimum value at each index16
for (let i = k + 1; i < nums.length; i++) {17
min = Math.min(min, nums[i]);21
// start with 2 pointers at opposite ends of nums23
let right = nums.length - 1;26
while (left <= right) {29
Math.min(nums[left], nums[right]) * (right - left + 1)32
// first to check if either pointer is at k33
// if it is at k then we must move the other pointer inwards36
} else if (right === k) {39
// if neither index is at k move the pointer40
// that is smaller inwards41
} else if (nums[left] < nums[right]) {