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 / ninad
public int check(int a[], int b[])
{
int x;
int[] c=new int[a.length];
for(int i=0; i<=c.length; i++)
{
c[i]=0;
}
for(int i=0; i<=a.length; i++)
{
for(int j=0; j<b.length; j++)
{
if(a[i]==b[j])
c[i]=1;
}
}
for(int i=0;i<=c.length;i++)
if(c[i]==0)
x=a[i];
return x;
}
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
i wanted to know about questions about c,c++ , which is required for placements.... im a fresher
What are the symptoms of stl?
What does stl mean in slang?
What does stl stand for in basketball?
What is a standard template library (stl)?
What is the stl, standard template library?
Who wrote stl?
If P is the population on the first day of the year, B is the birth rate, and D is the death rate, the estimated population at the end of the year is given by the formula: The population growth rate is given by the formula: B – D Write a program that prompts the user to enter the starting population, birth and death rates, and n, the number of years. The program should then calculate and print the estimated population after n years. Your program must have at least the following functions: 1. growthRate: This function takes its parameters the birth and death rates, and it returns the population growth rate. 2. estimatedPopulation: This function takes its parameters the current population, population growth rate, and n, the number of years. It returns the estimated population after n years Your program should not accept a negative birth rate, negative death rate, or a population less than 2. please answer my question ....
What is the use of stl?
totoo po ba ang manga aliens!
Is string part of stl?
Can we use stl in coding interviews?
How stl is different from the c++ standard library?
please visit this site you'll find my question this is my homework please answer it if you can http://easyscience.org/ib/lofiversion/index.php/t36168.html
What are stl algorithms?