← Read.ai Interview Insights

Read.ai·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Interviewed at read.ai, got a graph/string similarity problem that felt more like a warmup but ended up being trickier to get right than I expected.

Questions Asked (1)

Q1

Given two sentences as arrays of words and a list of similar word pairs, determine if the sentences are similar. Two sentences are similar if they're the same length and every pair of corresponding words is either identical or listed as similar (similarity is not directional).

Algorithms & Data Structures
Author's notes

Looked straightforward at first.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, check if the two sentences have the same length; if not, return false immediately. Then, build a hash set of normalized similar word pairs (e.g., sorted tuples) for O(1) lookups. Iterate through corresponding words and verify each pair is either identical or present in the set.

Pro tip: Mention that normalizing pairs by sorting ensures symmetry, and using a hash set gives O(n) time complexity. Also, clarify edge cases like empty sentences or duplicate pairs to show thoroughness.

1. Check Length

Compare the lengths of the two word arrays. If they differ, return false immediately.

2. Build Similarity Set

Create a hash set from the list of similar word pairs. For each pair (a, b), insert both (a, b) and (b, a) to handle non-directional similarity, or insert a normalized tuple like (min(a,b), max(a,b)).

3. Iterate and Validate

Loop through each index i. For each pair of words (word1[i], word2[i]), check if they are equal or if the normalized pair exists in the set. If any pair fails, return false.

4. Return Result

If all pairs pass, return true. Optionally, discuss time and space complexity: O(n + m) time and O(m) space, where n is sentence length and m is number of similar pairs.

Key Points to Mention

  • Length check as an early exit condition.
  • Using a hash set for O(1) average-case lookup of similar pairs.
  • Normalizing pairs (e.g., sorting) to enforce non-directional similarity.
  • Handling edge cases: empty sentences, duplicate pairs, or words similar to themselves.
  • Time complexity: O(n + m) where n is sentence length and m is number of similar pairs.
  • Space complexity: O(m) for storing the similarity set.

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