Find the Damaged Toy

Reported by candidates from Goldman Sachs's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Goldman Sachs OA. Under 2s to a working solution.
Founder's read

Goldman Sachs asked this in May 2024, and it's a classic array problem wrapped in toy-store language. You're given a list of toy IDs, and one is damaged (appears an odd number of times while others appear even). The OA doesn't give you the full problem text upfront, so you'll need to recognize the pattern fast. StealthCoder catches this instantly if you blank on the approach, but the trick is simple enough that knowing it now saves you five minutes of thinking under pressure.

Pattern and pitfall

This is a bit-manipulation problem at its core, though it also reads as a counting or hash-table problem if you're not careful. The naive path is to count occurrences with a dictionary, which works but feels slow. The elegant solution uses XOR: since XOR of two identical numbers is 0, and XOR is associative and commutative, XORing all elements leaves only the odd-count toy standing. You might also solve it with a set by toggling membership in and out. The catch is recognizing that 'damaged' means odd parity, not literally 'missing' or 'different'. If you implement a counting solution under time pressure, you'll pass, but interviewers often probe whether you know the XOR trick. StealthCoder can spot the pattern and feed you the XOR or set-toggle approach in real time if you freeze.

StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.

If this hits your live OA

You can drill Find the Damaged Toy 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. If you're reading this with an OA window open, you're who this was built for.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as single number. If you have time before the OA, drill that.

⏵ The honest play

You've seen the question. Make sure you actually pass Goldman Sachs's OA.

Goldman Sachs reuses patterns across OAs. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Find the Damaged Toy FAQ

Is this really just XOR, or is there a twist?+

It's XOR or set-toggle. Goldman likes this problem because it separates candidates who know the bit trick from those who brute-force with a hash map. Both pass, but the interviewer will ask follow-ups on why XOR works. Know that XOR of duplicates cancels to zero, leaving the odd one out.

What if multiple toys are damaged?+

The standard version has exactly one. If the problem says multiple, the approach changes (you'd track XOR values or use a different strategy). Read the constraint carefully. Goldman usually specifies 'exactly one damaged toy' to keep it tractable in the time limit.

Can I just use a dictionary to count?+

Yes, and you'll pass. Iterate once to count, iterate again to find the odd count. O(n) time, O(n) space. XOR is O(n) time, O(1) space, which is why it's the 'better' answer. For May 2024, either works, but expect a follow-up if you pick the dictionary route.

How much time do I actually have?+

Goldman's OA problems typically allow 30-45 minutes per question. This one shouldn't take more than 10-15 minutes if you recognize the pattern. If you're implementing a hash map, you have buffer. If you're debugging, you're cutting it close.

What's the real gotcha here?+

The language. 'Damaged' could mean 'missing value' or 'wrong value' or 'appears odd times.' Re-read the problem statement to confirm the definition. Once you know damaged means odd count, the solution is straightforward. Don't assume; the toy IDs are probably integers, not strings.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Goldman Sachs.

OA at Goldman Sachs?
Invisible during screen share
Get it