Return Records
Reported by candidates from Amazon's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Amazon's March 2024 OA is testing your ability to filter and return data efficiently. You've got a list of records and need to pull out only the ones matching a condition. The pattern is straightforward on the surface, but the trick is how you handle scale and edge cases without tanking on time or space. StealthCoder will catch the trick if you blank on the optimal filter logic.
Pattern and pitfall
This is a filtering problem dressed up as a database operation. You're iterating through records and returning a subset based on criteria. The temptation is to build intermediate arrays or overwrite the input. The real move is a single pass with early termination or a clean filter that scales. Common pitfall: candidates overthink it and add a hash table when a two-pointer or stream approach works. Amazon often layers in a secondary sort or condition to trip up the obvious solution. StealthCoder will have the pattern locked before you even finish reading the problem statement.
If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.
You can drill Return Records cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Amazon's OA.
Amazon reuses patterns across OAs. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Return Records FAQ
Is this asking me to modify the input array or return a new one?+
Check the problem statement for in-place vs. return. If it says in-place, two-pointer is your friend. If it's return, filter is cleaner. Amazon OAs usually specify this explicitly. The answer changes how you code it.
What if the records are huge and filtering is slow?+
Single pass, no extra space for intermediate lists. Use a pointer or iterator pattern if in-place. If you're building a new list, make sure it's unavoidable. Premature optimization kills candidates, but inefficient filters won't pass either.
How do I handle null or missing fields in a record?+
Amazon usually has test cases that hit this. Check the edge cases in the examples. If a record is incomplete, decide: skip it, return it, or throw. The problem will hint at the answer via example output.
Is sorting the result required, or just the filtering?+
Read the expected output carefully. If it shows sorted records, sort. If order doesn't matter, don't sort and save the time. Amazon's wording is usually clear on this point.
Can I solve this in 15 minutes?+
Yes. This is a warm-up or medium on Amazon's scale. The real test is clean code and handling edge cases without panic. If you're over 20 minutes, you're overthinking it.