PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep

Quick Overview

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.

  • Medium
  • Reevo
  • Coding & Algorithms
  • Software Engineer

Check strings against dictionary efficiently

Company: Reevo

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Take-home Project

Given a large dictionary of unique words and a list of query strings, return for each query whether it exists in the dictionary. The dictionary may contain up to 1,000,000 words and the query list up to 100,000 strings. Optimize for many queries and minimal memory overhead. Describe your chosen data structure(s), expected time and space complexity, and how you would handle case sensitivity, Unicode normalization, and duplicate queries.

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.

Given a large dictionary of unique words and a list of query strings, return for each query (in order) whether it exists in the dictionary. Implement `solution(dictionary, queries)` that returns a list of booleans where the i-th element is `true` if `queries[i]` is present in `dictionary`, and `false` otherwise. The dictionary may contain up to 1,000,000 words and the query list up to 100,000 strings, so optimize for many lookups: build a hash set from the dictionary once (O(N)) and answer each query in expected O(1). Comparison is exact and case-sensitive ('Cat' and 'cat' are distinct). Example: dictionary = ["apple", "banana", "cherry"] queries = ["apple", "grape", "cherry"] returns [true, false, true]

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

  1. Build a hash set from the dictionary once so each membership check is expected O(1) instead of scanning the whole list per query.
  2. Process queries in order and append the boolean result for each — duplicate queries simply produce repeated results.
  3. 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.
Last updated: Jun 26, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Output lexicographically largest DFS traversal - Reevo (medium)
  • Count all palindromic substrings - Reevo (medium)
  • Maximize weighted sum with disjoint adjacent swaps - Reevo (medium)