sir my code can print the elements which sum upto target
but i cannot remove duplicacy ,please help me.
so i miss one test case.
Sum it up regarding removing duplicacy
use the following approach
store all the elements in a map
now sort the array
now run a for loop for each element
at each step if the next element is same simply increment the counter
if it is not calculate requiredsum - arr[i] this is equal to remainingsum
search for this remaining sum in the map if found print both the elements
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.