Check strings against dictionary efficiently
Company: Reevo
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: Medium
Interview Round: Take-home Project
Quick Answer: This question evaluates skills in efficient membership testing for large datasets, memory-time trade-offs in data structures, and string handling concerns such as case sensitivity and Unicode normalization.
Constraints
- 0 <= len(dictionary) <= 1,000,000
- All words in dictionary are unique
- 0 <= len(queries) <= 100,000
- Comparison is exact and case-sensitive
- Strings consist of printable characters
Examples
Input: (['apple', 'banana', 'cherry'], ['apple', 'grape', 'cherry'])
Expected Output: [True, False, True]
Explanation: 'apple' and 'cherry' are in the dictionary; 'grape' is not.
Input: ([], ['apple'])
Expected Output: [False]
Explanation: Empty dictionary: no query can match.
Input: (['hello'], [])
Expected Output: []
Explanation: Empty query list returns an empty result list.
Input: (['a', 'b', 'c'], ['a', 'a', 'd', 'b'])
Expected Output: [True, True, False, True]
Explanation: Duplicate query 'a' yields True both times; 'd' is absent.
Input: (['Cat'], ['cat', 'Cat'])
Expected Output: [False, True]
Explanation: Case-sensitive: 'cat' does not match 'Cat', but 'Cat' does.
Hints
- Build a hash set from the dictionary once so each membership check is expected O(1) instead of scanning the whole list per query.
- Process queries in order and append the boolean result for each — duplicate queries simply produce repeated results.
- Be explicit about case sensitivity: by default exact comparison means 'Cat' != 'cat'. If you needed case-insensitive matching you would normalize (e.g. casefold) both the dictionary and the queries before inserting/looking up.