Algorithm · Akuna Capital · Medium
Requirements From an array of numbers, select a subsequence whose sum is as large as possible. Elements may be omitted, provided that no pair of neighboring array positions is omitted together. Notes Track two DP results at every position: take[i] represents the greatest total when val[i] is included, while skip[i] represents the greatest total when val[i] is excluded. Since adjacent exclusions are not allowed, excluding an item is only possible after including the preceding…
Checking your access…