We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
public static int migratoryBirds(List arr) {
// Write your code here
int f=0;
int b=0;
HashSet s=new HashSet<>(arr);
Iterator it=s.iterator();
while(it.hasNext())
{
int val=(int)it.next();
int a=(int)Collections.frequency(arr,val);
if(a>f)
{
f=a;
b=val;
}
else if(a==f)
{
if(val
Cookie support is required to access HackerRank
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 →
java
public static int migratoryBirds(List arr) { // Write your code here int f=0; int b=0; HashSet s=new HashSet<>(arr); Iterator it=s.iterator(); while(it.hasNext()) { int val=(int)it.next(); int a=(int)Collections.frequency(arr,val); if(a>f) { f=a; b=val; } else if(a==f) { if(val