Code Room
CodingEasycod-g1474
Subject Dynamic programming 1dLevel Entry–Mid~10 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

You are given a list of integers, each the net value of an optional task; values may be negative. You may complete any subset of the tasks, with one restriction: you can never complete two tasks that sit at adjacent positions in the list. Completing no tasks at all is allowed and scores 0. Return the maximum total value you can achieve. For example, [3, -2, 5] gives 8 by taking positions 0 and 2.

Implement
best_task_total(values: list[int]) → int
Examples
in[[3,-2,5]]out8
in[[-4,-1,-7]]out0
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.