Give two integer arrays A & B.A has n elements and B has ' n-1 ' elements . A has all the elements that are there in B. But B has one missing element. Write a function that takes arrays , A & B as imnput and finds the missing element in most optised manner .

Answer Posted / aniruddha

public int check(int a[], int b[])
{  int value,w;
   for(int i=0; i<=a.length; i++)
   {  w=0;
      for(int j=0; j<b.length; j++)
      {  
         if(a[i]!=b[j])
         {  w++;
            break;
         }
      }
      if(w==0)
      value=a[i];
   }
   return value;
}

Is This Answer Correct ?    12 Yes 9 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is stl open source?

848


write a program to convert a decimal number in to its equivalent binary number?

2272


What is stl language?

857


What are stl algorithms?

861


What is the use of stl?

825


How stl is different from the c++ standard library?

853


How do I convert a stl file?

771


Write a C/C++ program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the total number of disk writes by MySQL.

2180


What is the stl, standard template library?

831


What two types of containers does the stl provide?

754


how to use C++?

2257


What is stl in oop?

935


What does stl mean in slang?

844


Describe the My Computer and My Documents folders; identify the elements that are present in every Window.

2100


What is stl in c++ with example?

849