You are viewing a single comment's thread. Return to all comments →
public static int migratoryBirds(List<Integer> arr) { List<Integer> typeCountArray=new ArrayList<>(); int countMax=0; for(int i=1;i<6;i++){ int typeCount=0; for(int j=0;j<arr.size();j++){ if(arr.get(j)==i) typeCount++; } if(typeCount>countMax) countMax=typeCount; typeCountArray.add(typeCount); } int type=0; for(int i=0;i<typeCountArray.size()+1;i++){ if(typeCountArray.get(i)==countMax){ type=i+1; break; } } return type; }
Seems like cookies are disabled on this browser, please enable them to open this website
Migratory Birds
You are viewing a single comment's thread. Return to all comments →