Common elements in 3 sorted array

I am getting this error:

/usr/include/c++/5/bits/stl_algobase.h:246:17: error: __comp cannot be used as a function
if (__comp(__b, __a))

Question link:
https://practice.geeksforgeeks.org/problems/common-elements1132/1#

Hey @shivammishra2408

            int minimum=min(n1,min(n2,n3)); //corrected this ,this was giving error

There is something wrong in my logic too. Can you please check that.

            int minimum=min(n1,min(n2,n3)); //corrected this ,this was giving error
            
            for(int i=0;i<n1;i++){ //<n1 here because traversig on A
                
                if( a[A[i]] && b[A[i]] && c[A[i]] ){ //updated this
                    a[A[i]]=0;b[A[i]]=0;c[A[i]]=0; //added this because once added dont have to add again the same element
                    v.push_back(A[i]);
                }
            }

If this resolves ur query then please mark it as resolved :slight_smile:

1 Like

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.