# Rabbits In Forest

• ``````    answers.sort()
i,s=0,0
return s``````

• ``````public int numRabbits(int[] answers) {
int a[]= new int[1000];
}
int total=a[0];
for(int i=1;i<a.length;i++){
total+= a[i] != 0 && a[i]%(i+1)>0? (a[i] +((i+1)-(a[i]%(i+1)))):a[i];
}
}
``````

• i think there is a solution based on sorted array:

``````class Solution {

sum+=pre+1;
}else{
if(--cur<0){
sum+=pre+1;
}
}else{
sum+=pre+1;
}

}
}
return sum;
}
}
``````

• what is the significance of sending the complement of count[k] inside floorMod on line 8, tried reading the oracle docs on floorMod operation, it made little to no sense.

• @dejokz floorMod(k, m) is just the nonnegative value of k % m.
If there are say 2 rabbits that say 9, there are 10 total in that group, so we want -2 % 10 = 8 more.

• what if input is [1, 1, 1, 1], would there only be two rabbits since the first two and last two might be referring to one another? The code above gives 4 as answer

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.