The Count Common Words With One Occurrence interview question gives you two arrays of strings, words1 and words2. You need to find the number of strings that appear exactly once in words1 AND exactly once in words2.
Jane Street uses this Array interview pattern to test your basic data structure knowledge. It’s an "Easy" problem that evaluates whether you can use Hash Maps (or Dictionaries) to track frequencies efficiently. It checks for attention to detail—specifically, the "exactly once" constraint in both lists.
The problem uses Frequency Counting with Hash Maps.
words1.words2.words1 = ["a", "ab", "s"], words2 = ["b", "a", "s", "s"]
{a: 1, ab: 1, s: 1}.{b: 1, a: 1, s: 2}.For frequency problems, always consider the trade-off between using a Hash Map (general) and a fixed-size array (if the alphabet is small). In this case, since words are arbitrary strings, a Hash Map is the only way to go.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Find Words That Can Be Formed by Characters | Easy | Solve | |
| Kth Distinct String in an Array | Easy | Solve | |
| Most Common Word | Easy | Solve | |
| Find the Most Common Response | Medium | Solve | |
| Number of Pairs of Strings With Concatenation Equal to Target | Medium | Solve |