Pls check the error in my code

There seems to be some logical problem as it prints 5 instead of 3 as answer but I can’t figure it out.


pls help

at line 18 : of your code it should be
if(a[i] == a[j]){ instead of if(a[i] == a[j]){
also, add a condition that if k>0 only then compute op3
corrected code :-

1 Like

thanks a lot for your help @O17LPOLA020023

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.