How can i remove duplicate combinations in my code . for ex:
for input
3
1 1 2
3
my output
1 2
1 2
expected output
1 2
my code is https://ide.codingblocks.com/s/107744
How can i remove duplicate combinations in my code . for ex:
for input
3
1 1 2
3
my output
1 2
1 2
expected output
1 2
my code is https://ide.codingblocks.com/s/107744
Hi
For this I would suggest you to use unordered map, check if the number you are taking is present, if yes, use it and remove it from map, this way you will not get any duplicates
Sure, you can use set too but they are almost same
But have you tried using maps first? If yes, then pass on your code first. Lets try one approach at a time?
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.