Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Try to think of dynamic programming.
Use the idea of digit dynamic programming to build the numbers, in addition to a bitmask that will tell which digits you have used so far on the number that you are building.