Count Good Meals
A medium-tier problem at 32% community acceptance, tagged with Array, Hash Table. Reported in interviews at Robinhood and 1 others.
Count Good Meals is a medium-difficulty problem that shows up in online assessments at Robinhood and Swiggy. The 31% acceptance rate signals it trips up most candidates who haven't seen the pattern before. You're given an array and need to count pairs that satisfy some meal-related condition. The trick isn't math-heavy, but the naive O(n^2) approach will time out. This is exactly the kind of problem where you blank on the optimization mid-OA and lose 15 minutes. StealthCoder solves it invisible to the proctor so you move on and rack up points elsewhere.
Companies that ask "Count Good Meals"
Count Good Meals 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 by an Amazon engineer who watched the leaked-problem repo become an industry secret. He decided you should have it too.
Get StealthCoderCount Good Meals requires you to count pairs efficiently, which immediately points to a hash table. The naive approach checks every pair, which is too slow. Instead, you iterate once and track values you've already seen in a map. For each element, you check if a complementary value exists in the map. This shifts you from O(n^2) to O(n). Array and hash table are your core tools here. The gotcha: handling duplicates and making sure you're counting ordered pairs correctly. The low acceptance rate reflects that candidates either attempt brute force, hit time limit, or miscount pairs. When this problem appears live, you might freeze on the exact counting logic. StealthCoder gives you the working hash table solution in seconds so you nail the implementation and move forward.
Pattern tags
You know the problem.
Make sure you actually pass it.
Count Good Meals 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 by an Amazon engineer who watched the leaked-problem repo become an industry secret. He decided you should have it too. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Count Good Meals interview FAQ
Is Count Good Meals still asked at Robinhood and Swiggy?+
Yes. Both companies have it in their recent interview reports. With a 31% pass rate, it's clearly still a filter problem. If it comes up in your OA, you're expected to know the hash table optimization. Prep it.
What's the actual trick to Count Good Meals?+
Use a hash table to track values as you iterate. For each element, check if its complement exists in the map. This converts O(n^2) brute force into O(n). The trick is realizing you don't need nested loops once you think hash table first.
How does the hash table approach actually work?+
Iterate through the array once. Store each value in a map with its count or frequency. For each element, calculate what would make a valid pair and check if that value exists in the map. Count valid pairs as you go. This single pass beats checking all combinations.
Why is the acceptance rate so low at 31%?+
Most candidates either attempt O(n^2) and time out, or miscount pairs when duplicates exist. The hash table solution is clean once you see it, but under live assessment pressure, the pair-counting logic trips people up. It's a filter problem by design.
Will this problem test my array and hash table skills equally?+
Hash table is the core. Array skills matter for iteration and indexing, but the problem is really about recognizing when to abandon nested loops and trade space for time. Hash table knowledge is what separates pass from fail.
Want the actual problem statement? View "Count Good Meals" on LeetCode →