The core idea: = answer for the subset represented by mask. Your DP (dynamic programming) table has entries, one per subset. Transitions typically add or remove one element, connecting to .
You build larger subsets from smaller ones, or vice versa. Time complexity is typically if each state checks transitions, or if transitions involve pairs. For , that's million or million operations, both feasible.