it took me around 5 hours to make this code.
can u pls see and give me a more better approach to solve this question?
Sum it up question
The approach you used is perfect. But there is a little optimization that we can do here.
After you sorted the array, remove the duplicate from it, i.e. make another array with only distinct numbers, this will reduce the time cost. And instead of a set of vectors, you can make a vector of vectors to save some space as well.