Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Keep the banned numbers that are less than or equal to n in a set.
Loop over the numbers from 1 to n and if the number is not banned, use it.
Keep adding numbers while they are not banned, and their sum is less than or equal to k.