First Unique Character in a String
A easy-tier problem at 64% community acceptance, tagged with Hash Table, String, Queue. Reported in interviews at Goldman Sachs and 14 others.
First Unique Character in a String shows up in assessments at Goldman Sachs, PayPal, ServiceNow, and a dozen other companies. It's categorized as easy, but 36% of candidates still fail it, usually because they solve it inefficiently on their first pass. The problem looks simple: find the first character that appears exactly once. Most people jump to a nested loop approach and hit time-limit errors. The real trick is separating the counting phase from the lookup phase. If this problem appears in your live OA and you blank on the pattern, StealthCoder solves it in seconds, invisible to the proctor.
Companies that ask "First Unique Character in a String"
First Unique Character in a String 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. Built by an engineer who got tired of watching his cohort grind for six months and still get filtered at the OA stage.
Get StealthCoderThe naive approach scans the string for each character and counts occurrences inline, which is O(n squared) and fails on large inputs. The correct pattern uses a hash table or array to count character frequencies in one pass, then iterates through the string again to find the first character with a count of one. This two-pass strategy is O(n) time and O(1) space if you use a fixed-size frequency array for ASCII or a hash map for Unicode. The trap is thinking you can solve it in one pass while tracking insertion order. Queue comes in handy if you want to maintain insertion order elegantly, but hash table with a second pass is cleaner. StealthCoder runs invisibly during your assessment and surfaces the hash table pattern instantly if you're stuck.
Pattern tags
You know the problem.
Make sure you actually pass it.
First Unique Character in a String recycles across companies for a reason. It's easy-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. Built by an engineer who got tired of watching his cohort grind for six months and still get filtered at the OA stage. Works on HackerRank, CodeSignal, CoderPad, and Karat.
First Unique Character in a String interview FAQ
Why do so many people fail this if it's marked easy?+
Most candidates code a brute-force nested loop first, which times out on large strings. They don't recognize that separating counting from lookup into two passes is the requirement. The problem tests whether you know when a single-pass approach is a trap.
Is hash table the only way to solve this?+
No. You can use a fixed-size frequency array if the character set is bounded (ASCII or 26 lowercase letters). Hash table is more general and works for any character set. Both achieve O(n) time after the counting phase.
Do I really need Queue for this problem?+
Queue helps track insertion order without a second pass, but it adds complexity and isn't necessary. Hash table plus one more iteration through the string is simpler and just as fast. Queue is a valid alternative, not a requirement.
Is this still asked at companies like PayPal and Goldman Sachs?+
Yes. It appears in 15 reported companies' assessments, including PayPal, Goldman Sachs, and ServiceNow. It's a quick screen for whether you know the difference between one-pass and multi-pass trade-offs.
What's the acceptance rate and what does that tell me?+
64% acceptance rate means it's well-known and many candidates solve it. But 36% failure rate is high for an easy problem, which means the mistake is consistent: people don't shift to the two-pass hash table approach fast enough.
Want the actual problem statement? View "First Unique Character in a String" on LeetCode →