n = nums.length
, left = k
, right = k
, ans = nums[k]
, and currMin = nums[k]
.left > 0
or right < n - 1
:
nums[left - 1]
with nums[right + 1]
.nums[right + 1]
is greater, increment right
and update currMin
with nums[right]
if it is lower.left
and update currMin
with nums[left]
if it is lower.ans
with currMin * (right - left + 1)
if it is greater.ans
.