Rabbits in Forest
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
A forest contains an unknown number of rabbits, each with some color. You asked some of them the same question: "How many **other** rabbits share your color?" Their answers are stored in answers, where answers[i] is the reply of the i-th rabbit you asked. Every rabbit answers truthfully.
Return the **minimum** possible number of rabbits in the forest that is consistent with all the answers (counting both the rabbits you asked and any you did not).
Examples
Constraints
- `1 <= answers.length <= 1000`
- `0 <= answers[i] < 1000`
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.