MEDIUMasked at 4 companies

Rabbits in Forest

A medium-tier problem at 58% community acceptance, tagged with Array, Hash Table, Math. Reported in interviews at Cleartrip and 3 others.

Founder's read

Rabbits in Forest is a medium-difficulty array problem that hits candidates from Cleartrip, Wish, CARS24, and Zepto. The problem looks straightforward at first, you're given rabbits and their colors, and you need to figure out group structure, but most people try to brute-force it and run into walls. The trick is recognizing that you don't actually need to simulate anything. Your greedy approach cuts the runtime in half. With a 58% acceptance rate, it's a classic filter problem: candidates who see the pattern pass cleanly, those who don't get stuck. If this shows up in your assessment and you blank on the greedy insight, StealthCoder surfaces a working solution in seconds, invisible to the proctor.

Companies asking
4
Difficulty
MEDIUM
Acceptance
58%

Companies that ask "Rabbits in Forest"

If this hits your live OA

Rabbits in Forest is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Made for the engineer who has done the work but might still blank with a webcam pointed at him.

Get StealthCoder
What this means

The core insight is math, not simulation. You're told each rabbit reports how many rabbits of the same color it sees. If a rabbit sees N other rabbits of its color, it's in a group of at least N+1. Greedy observation: each rabbit with report count R must belong to a group of exactly R+1 rabbits, because if the group were larger, it would see more. So you iterate through reports, track how many rabbits you've already assigned to groups of each size, and only add new groups when needed. The pitfall is overthinking: candidates often try to simulate group assembly or use heavy hash table logic when a single pass with a counter map wins. Hash table is there to track group sizes you've already filled. Array iteration is straightforward. When you hit the live assessment and panic, StealthCoder reads the problem and hands you the greedy template instantly.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Rabbits in Forest recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Made for the engineer who has done the work but might still blank with a webcam pointed at him. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Rabbits in Forest interview FAQ

Is this really asked at Cleartrip, Wish, CARS24, and Zepto?+

Yes. All four companies have live reports of asking it. It's a legitimate OA question at scale, not a rarity. The 58% acceptance rate confirms it's no joke, just over half of candidates who attempt it pass.

What's the actual trick that separates pass from fail?+

Recognizing that each rabbit's count directly constrains group size. A rabbit seeing R others of the same color means group size is exactly R+1, not 'at least' or 'maybe'. Once you lock that, greedy assignment becomes obvious and simulation unnecessary.

Do I really need a hash table for this, or is it just array and math?+

Hash table is optimal. You use it to track how many rabbits you've assigned to groups of each size, then count how many new groups you had to create. Array holds the input. Math tells you group sizes. Hash table glues them together cleanly.

Why do so many candidates get this wrong if it's medium difficulty?+

Because they simulate. They try to build groups step by step or validate group membership explicitly, which bloats the code and often fails on edge cases. The greedy insight cuts through that noise, but you have to see it first.

How long should this take me to solve if I know the pattern?+

Once you see the greedy constraint, 5 to 10 minutes for code and basic testing. Most failures come from not seeing the pattern at all, not from implementation. If you blank during your assessment, that's where StealthCoder bridges the gap.

Want the actual problem statement? View "Rabbits in Forest" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.