Question
You are given a non-empty integer array and a number k >= 1. You must perform exactly k operations; each operation picks one index and flips the sign of that element, and the same index may be picked any number of times. Return the largest possible array sum after the k operations. Example: nums [3, -1, 0, 2] with k = 3 gives 6 — flip -1 once, then burn the remaining two flips on the 0.
max_sum_after_flips(nums: list[int], k: int) → int[[3,-1,0,2],3]out6State 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.