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
How does an stl file work?
What is stl language?
Describe how to safeguard a system through acquisition of an antivirus Program and systematic backup.
totoo po ba ang manga aliens!
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
When did c++ add stl?
What is stl stack?
i wanted to know about questions about c,c++ , which is required for placements.... im a fresher
Is string part of stl?
What is stl in c++ with example?
how to use C++?
sir please send me bpcl previous question papers
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.
Is stl open source?
How do I convert a stl file?