EASYasked at 1 company

Count Common Words With One Occurrence

A easy-tier problem at 72% community acceptance, tagged with Array, Hash Table, String. Reported in interviews at Jane Street and 0 others.

Founder's read

You're scanning two lists of words and need to count how many appear in both lists with exactly one occurrence in each. Jane Street has asked this. It's an easy problem on paper, but the implementation details matter more than the algorithm. If you miscount frequencies or misunderstand the constraint (one occurrence, not more), you'll fail cases silently. Most candidates skip the hash table step and try a naive approach that works on small inputs but scales poorly. StealthCoder solves it invisibly during your assessment if you blank on the frequency-counting pattern.

Companies asking
1
Difficulty
EASY
Acceptance
72%

Companies that ask "Count Common Words With One Occurrence"

If this hits your live OA

Count Common Words With One Occurrence 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 at a top-10 tech company who can solve these problems cold but didn't want to trust himself in a 90-minute screen share.

Get StealthCoder
What this means

The trick is treating this as a frequency-counting problem, not a membership problem. You can't just check if a word is in both lists. You need to count occurrences of each word in list A and list B separately, then count how many words have a frequency of exactly 1 in both. Hash tables (dictionaries or sets) are the natural tool. The gotcha: candidates often try to use a single set and get the logic wrong, or they count frequencies in only one list. The straightforward path is two passes with hash tables: count words in list A, count words in list B, then iterate and check if a word exists with frequency 1 in both. It's O(n + m) time and space. The acceptance rate is strong (72%), so most people who attempt it get there, but the simplicity masks common mistakes during live assessments.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Count Common Words With One Occurrence 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 at a top-10 tech company who can solve these problems cold but didn't want to trust himself in a 90-minute screen share. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Count Common Words With One Occurrence interview FAQ

Is this really just a hash table problem or is there a trick?+

No secret algorithm. The trick is discipline: count frequencies in both lists separately, then find words with count == 1 in both. Most failures come from confusion about what you're counting, not the data structure. Hash tables are enough.

Will Jane Street ask harder variants of this in follow-ups?+

Possibly. Once you solve the base problem, interviewers might ask for optimizations, multiple lists, or weighted occurrences. The foundation here is understanding frequency counts, which applies to all variants.

How do I avoid off-by-one errors in counting?+

Initialize your hash table counts at 0 or use defaultdict. Iterate once per list, incrementing counts. Then iterate through one hash table and check the other. Write assertions for small examples first.

Should I use a set or a hash map for this?+

Hash map (dictionary). Sets only track membership, not frequency. You need to store the count of each word, so a hash map with word as key and count as value is the right structure.

Why is the acceptance rate so high if this is asked at top firms?+

The problem is genuinely easy once you know the pattern. Jane Street asks it partly to filter out people who can't write clean, bug-free code under pressure, not because the algorithm is hard.

Want the actual problem statement? View "Count Common Words With One Occurrence" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.