#1802
Maximum Value at a Given Index in a Bounded Array
expert · 1035 · lc medium +32 · verified · 38.9% accepted · 2,715 likes · top 18%
Description
Construct a 0-indexed array nums of length n with positive integers satisfying: adjacent elements differ by at most 1; the total sum does not exceed maxSum; and nums[index] is maximized. Return nums[index].
Code
1
2
3