3 Sum (Leetcode)

in my code it includes duplicate cases as well… how to avoid that

Hi chaman … your approach is fine and good you just need to add few nested while loops where in you are supposed to increase and decrease your pointers till they are equal to their previous values . like
while(arr[j]==arr[j-1]) j++. kind of like this.

Hi @Madeshi-Chinmay-2159857244260221 i was expecting a better ans from your side.
i know my approach is fine and that all.

my ques was how to exclude duplicate triplets. so can you please answer that

I just gave you the hint to exclude duplicates … you need to move both your pointer such that the current values at your pointers doesn’t match the previous ones.

Or you can refer to here for more detailed explanation.

@Madeshi-Chinmay-2159857244260221 thank you it is solved now