Rabbits in Forest
There is a forest with an unknown number of rabbits. We asked n rabbits "How many other rabbits have the same color as you?" and collected the answers in an integer array answers where answers[i] is the answer of the i^th rabbit.
Given the array answers, return the minimum number of rabbits that could be in the forest.
Example 1
Input
answers = [1,1,2]Output
5The two rabbits that answered "1" could both be the same color, while the rabbit that answered "2" must be a different color with 2 additional same-colored rabbits not in the array, so the minimum is 5.
Example 2
Input
answers = [10,10,10]Output
11All three rabbits that answered 10 can belong to one color group of size 11, so the minimum number of rabbits is 11.
Constraints
- 1 <= answers.length <= 1000
- 0 <= answers[i] < 1000