dp with size 1 << (2 * numSlots) and fill it with -1, representing uncalculated states.solve that takes the current index of nums, the current state of the bitmask, and the number of slots.solve, if the current index is equal to the length of nums, return 0 (base case).dp, return the stored value.solve with the next index and the updated bitmask.dp for the current state.solve(0, 0, numSlots).dp with all bits set (all numbers placed).