3 ms·
The easiest solution: Sort from largest to smallest. Then just do a DFS. Or, if you're so inclined, pay attention to the 1s digit. You know the digit has to add
by ggggtez 5y ago
The easiest solution: Sort from largest to smallest. Then just do a DFS. Or, if you're so inclined, pay attention to the 1s digit. You know the digit has to add to exactly 4, because there is an exact fit. The search space is not 20^20, it's not even close.