Question
Given n (number of bits) and an array val of length 2**n where val[m] is a weight assigned to subset m, for each mask m compute the maximum val[s] over all submasks s of m (s & m == s). Return the array of these per-mask submaximums. Constraints: 1 <= n <= 14. The SOS-style DP generalizes from sum to max in O(n * 2**n); naive submask enumeration is O(3**n) and too slow at the top.
max_over_submasks(n: int, val: list[int]) → list[int][2,[4,1,7,2]]out[4,4,7,7]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.