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 / abhi

#include<iostream>
using namespace std;
#include<algorithm>
int main()
{
int n;
cin>>n;
int a[n],b[n-1];
int sum1=0,sum2=0;
for(int i=0;i<n;i++)
{
cin>>a[i];
sum1+=a[i];
}
for(int i=0;i<n-1;i++)
{
cin>>b[i];
sum2+=b[i];
}
cout<<sum1-sum2<<endl;



}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a standard template library (stl)? What are the various types of stl containers?

913


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

2271


What is a stl vector?

826


a program using one dimensional array that searches a number if it is found on the list of given input numbers given by the user and locate its exact location in the list.

1604


i wanted to know about questions about c,c++ , which is required for placements.... im a fresher

1918


write a program that will accept a number and print.its equivalent in words the maximum input number is 9999

2704


What is a list in c++ stl?

890


Do you like to Submit Questions in Bulk under Same Category?? Then use our Bulk ListerDo you like to Submit Questions in Bulk under Same Category?? Then use our Bulk Lister

1865


What is stl in oop?

933


Explain stl.

1095


What is the use of stl?

825


help me i need a c++ program which takes sequesnce of characters and outputed sequence of their token taypes, work same compiler in lexical analysis phase

2134


What are stl algorithms?

861


how to use C++?

2256


How do I convert a stl file?

771