Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

<?php
function findMissing($a1, $a2) {
for($i= 0; $i<count($a1); $i++) {
$found = false;
for($j= 0; $j<count($a2); $j++) {
if($a1[$i] == $a2[$j] ) {
$found = true;
break;
}
}
if($found == false) {
break;
}


}
return $a1[$i];
}

$element = findMissing(array(1, 3, 5, 7, 9, 10, 6), array(1, 3, 7, 9, 10, 6));

echo "Missing Element in second Array : " . $element;
?>

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How does an stl file work?

1146


What is stl language?

1141


Describe how to safeguard a system through acquisition of an antivirus Program and systematic backup.

2177


totoo po ba ang manga aliens!

2777


To modify an, existing worksheet. What steps are involved for: 1. Inserting and deleting rows and columns. 2. Printing cell formulas 3Jld displayed values 3. Using the page setup command

2229


When did c++ add stl?

1224


What is stl stack?

1121


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

2206


Is string part of stl?

1200


What is stl in c++ with example?

1155


how to use C++?

2545


sir please send me bpcl previous question papers

2393


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.

2443


Is stl open source?

1133


How do I convert a stl file?

1097