Amazon Interview Question
Applications DevelopersCountry: India
Interview Type: Written Test
public int[] mergeTwo(int[] a, int[] b){
int i = 0, j = 0, k = 0;
int[] final = new int[a.length-1 + b.length -1];
while (i < a.length && j < b.length){
if(a[i] < b[j]){
final[k++] = a[i++];
}
else { final[k++] = b[j++];}
}
while (i < a.length){
final[k++] = a[i++];
}
while (j < b.length){
final[k++] = b[j++];
}
}
what ?you need to be specific about the question.
- sachin August 25, 2012