This question evaluates understanding of dynamic programming and array-based optimization, assessing competency in designing algorithms that maximize a sum under adjacency constraints.
Given an array of non-negative integers nums, choose a subset of elements such that no two chosen elements are adjacent in the original array.
Return the maximum possible sum of the chosen elements.
nums
: array of integers,
0 <= nums[i]
1 <= n <= 10^5
0 <= nums[i] <= 10^9
nums = [1,2,3,1]
→
4
(choose
1
and
3
)
nums = [2,7,9,3,1]
→
12
(choose
2, 9, 1
)