Interview Questions

Given 2 sorted integer arrays, find the intersecting element in them.

Software QA/Tests Interview Questions from Microsoft


(Continued from previous question...)

Given 2 sorted integer arrays, find the intersecting element in them.

Q:
Microsoft Interview Question for SDE in tests
Given 2 sorted integer arrays, find the intersecting element in them.


A:
let the two arrays be array1[]
array2[]
for(i=0; j=0; i<array1.length(); j<array2.length();) {
if(array1[i]== array2[j]) {
print("found the element %d", array1[i]);
} else if (array1[i] < array2[j]) i++;
else j++;
}

(Continued on next question...)

Other Interview Questions