You are viewing a single comment's thread. Return to all comments →
I have done using bucket concept. Except one test case all other are failing. Feedback needed:
` static int migratoryBirds(int[] ar) {
int[] bucket = new int[5]; for(int i=0;i<ar.length;i++){ int j = 5-((ar[i])%5); bucket[j-1]++; // } int highest = 0; int answer = 0; for(int i = 0;i<bucket.length;i++){ if(bucket[i]>highest){ highest = bucket[i]; answer= i+1; } } return answer; } ```
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 →
I have done using bucket concept. Except one test case all other are failing. Feedback needed:
` static int migratoryBirds(int[] ar) {