First Occurence
Reported by candidates from Linkedin's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
LinkedIn's September OA threw this one at candidates and it's deceptively simple on the surface. You're looking for the first occurrence of something, which sounds like a warm-up problem until you realize the input size or the gotcha they've hidden. StealthCoder reads the problem statement in real time and spots the edge case you'd normally miss under pressure. The pattern is straightforward, but LinkedIn loves testing how cleanly you handle boundary conditions and think through the problem before you code.
Pattern and pitfall
First Occurrence problems almost always test your ability to iterate efficiently and know when to stop. The common mistake is over-engineering a solution when a single pass works fine. You're scanning through a data structure (array, string, or similar), tracking what you've seen, and returning the index or value of the first element that meets the criteria. The trick is usually in what 'first' means in context: first unique character, first non-repeating element, first position where a condition holds. LinkedIn often pairs this with a hash table or frequency counter to track context as you move forward. If you blank on the logic during the live OA, StealthCoder is your safety net, giving you the exact structure and edge cases to check.
StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.
You can drill First Occurence 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 StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Linkedin's OA.
Linkedin 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.
First Occurence FAQ
Is this really an 'easy' problem at LinkedIn?+
On paper, yes. The algorithm is simple. But LinkedIn uses it to check your coding discipline: do you handle empty inputs, single elements, and 'not found' cases correctly. That's where candidates slip up. Speed matters less than completeness here.
Do I need a hash table or hash set?+
Depends on the exact problem statement. If you need to track frequency or uniqueness, yes. If you're just scanning for a condition, you might not. Read the problem text carefully before you code. The pattern guides the data structure, not the other way around.
What's the most common edge case LinkedIn tests?+
No occurrence found. You need to return -1, null, or handle it explicitly. Also: what if the first element itself matches the criteria. Test your logic with trivial inputs before submitting.
Can I solve this in one pass?+
Almost always yes. If you're iterating twice, you're probably overcomplicating it. One pass forward with a counter or set to track state is the standard approach.
How do I prepare in 48 hours?+
You don't need to. Understand what 'first' means in the problem statement, sketch the algorithm on paper, think through three test cases including edge cases, and code it clean. That's the prep.