I Feel Ducky

Leetcode #781 - Rabbits in Forest

There is a forest with an unknown number of rabbits. We asked n rabbits:

β€œHow many rabbits have the same color as you?”

Each rabbit replied with a number, and we collected these answers in an integer array answers, where answers[i] is the response of the i-th rabbit.

Your task is to determine the minimum number of rabbits that could be in the forest based on these replies.


πŸ” Example 1

Input:
answers = [1, 1, 2]

Output:
5

Explanation:

So the minimum number of rabbits is:


πŸ” Example 2

Input:
answers = [10, 10, 10]

Output:
11

Explanation:


βœ… Constraints

🎯 Would you like to try it yourself? Click here to solve it on Leetcode!

πŸ€” Curious how I did? [Check out my solution!] (https://leetcode.com/problems/rabbits-in-forest/solutions/6674788/leetcode-781-rabbits-in-forest-by-cpn3kq-qri3/)

#Algorithms #Array Problems #Ceiling Division #Coding Interview #Counting #Go #Golang #Greedy #Grouping #Hash Map #Leetcode #Math #Problem Solving #Time Complexity