employer cover photo
employer logo
employer logo

Mindstix Software Labs

Engaged Employer

Mindstix Software Labs Interview Question

Array programs. compare two arrays. find largest element in array. array length will vary. (not same length arrays will be given)

Interview Answer

Anonymous

Sep 6, 2019

int arr1[]={20,65,23056,67,678}; int arr2[]={76,23,4545,98,90909}; int len1=arr1.length; int len2=arr2.length; int max1=arr1[0]; for(int i=0;imax1){ max1=arr1[i]; } } int max2=arr2[0]; for(int j=0;jmax2){ max2=arr2[j]; } } if(max1>max2){ System.out.print("max element is:"+max1); } else{ System.out.print("Max element is: "+max2); }