← HarveyAI Interview Insights

HarveyAI·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

Coding screen for a software engineer role at HarveyAI. One question, pretty focused on string parsing logic. Nothing crazy but the whole-word matching constraint is where people trip up.

Questions Asked (1)

Q1

Given a list of sentences and a list of tag words, count how many sentences contain at least one tag as a whole word (case-insensitive, no substring matches).

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

The substring trap is real here.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the requirements and edge cases first, then propose an efficient algorithm using tokenization and a hash set for O(1) tag lookups. Discuss trade-offs between preprocessing (e.g., tokenizing sentences once) and on-the-fly checking, and analyze time/space complexity.

Pro tip: Mention that you'd use a regex with word boundaries (\b) to ensure whole-word matching, but also consider Unicode and punctuation handling. Show awareness of performance by suggesting early termination once a tag is found in a sentence.

1. Clarify Requirements

Ask about input size, definition of 'whole word' (e.g., punctuation, hyphens, Unicode), and whether tags can overlap. Confirm case-insensitivity and that a sentence counts if any tag matches.

2. Choose Data Structures

Use a hash set for tags to enable O(1) membership checks. Tokenize each sentence into words, stripping punctuation, and compare each token against the set.

3. Algorithm Design

Iterate through sentences; for each, tokenize and check each token against the tag set. If a match is found, increment the count and break early to avoid unnecessary checks.

4. Handle Edge Cases

Consider empty sentences, empty tag list, tags with special characters, and case variations. Ensure tokenization correctly handles punctuation and Unicode word boundaries.

5. Analyze Complexity

Time: O(S * W) where S is number of sentences and W is average words per sentence, assuming O(1) set lookups. Space: O(T) for the tag set, where T is number of tags.

Key Points to Mention

  • Use a hash set for O(1) tag lookups
  • Tokenization with word boundaries (e.g., regex \b) to avoid substring matches
  • Case-insensitive comparison (e.g., lowercase both tokens and tags)
  • Early termination within a sentence once a tag is found
  • Trade-offs: preprocessing all sentences vs. on-the-fly tokenization
  • Complexity analysis: O(S * W) time, O(T) space

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.