Test cases failing not sure why!
for i/p
6
1 2 3 3 5 6
o/p
should be 14
ur code shows 56
please u need to thing a little more on the way u are approaching the problem
Hi,
Isn’t the answer for the array you have given 12?
{1 2 3 3 5 6}
1, 2, 3, 5, 6, {1 2], {2 3}, {3 5}, {5 6}, {1 2 3}, {3 5 6}
Also, I ran through the hint video given for this question. In it, when it calculates for say {1 2 3}, then it also calculates for {2 3}. Won’t it lead to double counting of {2}, {3}, {2 3}.
I am confused right now.
dekho yr
we move the j pointer upto the point till we find the value in the set
as soon as the jth pointer element is found in the set
we calculate the sum
and move the i pointer by one and remove that element from the set
again check if the jth element is present or not if yes move i th pointer 1 right do follow this until i == j or jth element is not present in set
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.