This is a problem that fits naturally to a recursive solution. I’m not sure how I’d implement without recursion. The recursion automatically does a backtrack to find valid solutions. By starting the search for sub-items from the current item and bigger, we eliminate duplicates as the numbers will be in ascending order. Here are my whiteboard notes:
![](https://www.adamk.org/wp-content/uploads/2019/06/whiteboard-leetcode39-1024x768.jpg)
And the c++ source code for my solution: