#include<iostream>
using namespace std;
int main(){
cahr ch='a';
}
//Enter you code here.
//Please indent properly.
<?php
//program to find the common elements of the two array
//here we have to array A and B from which w have to find the common element
//first we sort then using merge sort and after then for traversing through
//the array in one iteration we can find the comman elements the given array
//this is an inspace algorithm meansno extra space is needed
//best case time complexity=O(nlogn)
//O(nlogn)-> for sorting
//O(n)-> for while loop to find comman element
//average case time complexity=O(nlogn)
//O(nlogn)-> for sorting
//O(n)-> for while loop to find comman element
//worst case time complexity =O(nlogn)
//O(nlogn)-> for sorting
//O(n)-> for while loop to find comman element
$A=array(3,4,5,6,7,8,9,10,36,58,27,48); $B=array(3,10,4,5,6,8,12,24,37,27,50); $counter1=0;
$counter2=0;
while(($counter1< $size1) && ($counter2)<($size2))//traversing through the array
{
if ($A[$counter1] == $B[$counter2])
{
array_push($commonArray,$A[$counter1]); //to enter comman element in the output array $counter1=$counter1+1;
$counter2=$counter2+1;
}
else if ($A[$counter1] < $B[$counter2])
{
$counter1=$counter1+1; }
else
{
$counter2=$counter2+1;
}
}
print_r($commonArray);//to print the output array ?>
I2luY2x1ZGU8aW9zdHJlYW0+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmludCBtYWluKCl7CgljYWhyIGNoPSdhJzsKfQovL0VudGVyIHlvdSBjb2RlIGhlcmUuCi8vUGxlYXNlIGluZGVudCBwcm9wZXJseS4KCjw/cGhwCi8vcHJvZ3JhbSB0byBmaW5kIHRoZSBjb21tb24gZWxlbWVudHMgb2YgdGhlIHR3byBhcnJheQovL2hlcmUgd2UgaGF2ZSB0byBhcnJheSBBIGFuZCBCIGZyb20gd2hpY2ggdyBoYXZlIHRvIGZpbmQgdGhlIGNvbW1vbiBlbGVtZW50Ci8vZmlyc3Qgd2Ugc29ydCB0aGVuIHVzaW5nIG1lcmdlIHNvcnQgYW5kIGFmdGVyIHRoZW4gZm9yIHRyYXZlcnNpbmcgdGhyb3VnaAovL3RoZSBhcnJheSBpbiBvbmUgaXRlcmF0aW9uIHdlIGNhb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