troubleshooting Question

number common in 4 sorted arrays

Avatar of shragi
shragiFlag for India asked on
ProgrammingJavaJava EE
5 Comments1 Solution245 ViewsLast Modified:
I had a 4 arrays... I want to know the numbers common in all 4 arays...

my method.... run 4 for loops and verify each element....

for (int p=0; p<array1.len;p++)
{
   for (int j=0; j<array2.len;j++)  
    {
       if(array1[p]=array2[j])
       {
           for (int k=0; k<array3.len;k++)
             {
               if(array1[p]= array3[k]
              {
                  for (int m=0; m<array4.len;m++)
                   {
                      if (array1[p]= array4[m])
                      return array1[p];
                    }
               }
        }
}
}
}
}


but this not an effective method.... can some one suggest me an efficient method....
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros