Three of my accounts recently achieved the #1, #2 and #3 leetcode ratings in South Korea. lol 😂
Leetcode contest speed-run global rank 2nd
3430. Maximum and Minimum Sums of at Most Size K Subarrays
You are given an integer array
nums
and a positive integerk
. Return the sum of the maximum and minimum elements of all subarrays with at mostk
elements.
You are given an even integer
n
representing the number of houses arranged in a straight line, and a 2D arraycost
of sizen x 3
, wherecost[i][j]
represents the cost of painting housei
with colorj + 1
.The houses will look beautiful if they satisfy the following conditions:
- No two adjacent houses are painted the same color.
- Houses equidistant from the ends of the row are not painted the same color. For example, if
n = 6
, houses at positions(0, 5)
,(1, 4)
, and(2, 3)
are considered equidistant.Return the minimum cost to paint the houses such that they look beautiful.
3428. Maximum and Minimum Sums of at Most Size K Subsequences
You are given an integer array
nums
and a positive integerk
. Return the sum of the maximum and minimum elements of all subsequences ofnums
with at mostk
elements.Since the answer may be very large, return it modulo
109 + 7
.
3427. Sum of Variable Length Subarrays
You are given an integer array
nums
of sizen
. For each indexi
where0 <= i < n
, define a subarraynums[start ... i]
wherestart = max(0, i - nums[i])
.Return the total sum of all elements from the subarray defined for each index in the array.