Frage im Vorstellungsgespräch bei Mindstix Software Labs

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

Antwort im Vorstellungsgespräch

Anonym

6. Sept. 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); }