← Amazon Interview Insights

Amazon·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
May 2026

Summary

Amazon SWE interview with a DP-heavy coding problem. Nothing too surprising but it required knowing your way around word break style recursion with memoization.

Questions Asked (1)

Q1

Given an array of strings, find all words in the array that can be formed by concatenating two or more other words from the same array.

Algorithms & Data Structures
Author's notes

Classic word break variant but applied across the whole list, which trips you up if you just think about it as a single string problem.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Use a set for O(1) lookups and for each word, recursively check if it can be segmented into two or more smaller words from the set. Optimize with memoization to avoid redundant computations and handle edge cases like empty strings and duplicates.

Pro tip: Clarify whether a word can be formed by concatenating two or more words, and whether the same word can be reused. Also, discuss trade-offs between recursive memoization and iterative DP, and mention that sorting by length can help process smaller words first.

1. Clarify requirements and edge cases

Ask if words can be reused, if the concatenation must use at least two words, and how to handle duplicates or empty strings. Confirm the expected output format.

2. Choose data structures

Store all words in a hash set for O(1) lookups. Optionally, sort words by length to process shorter words first, which can simplify recursion.

3. Design the algorithm

For each word, recursively check if it can be split into a prefix that is a word in the set and a suffix that is either a word or can be further split. Use memoization to cache results for each word.

4. Implement and test

Write clean code with helper functions. Test with edge cases: no concatenated words, all words concatenated, overlapping words, and large inputs to ensure efficiency.

5. Analyze complexity and optimize

Discuss time and space complexity. With memoization, time is O(n * L^2) where n is number of words and L is max length, but can be optimized with trie or DP.

Key Points to Mention

  • Use a hash set for O(1) word lookups.
  • Recursive segmentation with memoization to avoid repeated work.
  • Ensure at least two words are used in the concatenation.
  • Handle edge cases: empty strings, duplicates, and words that are prefixes of others.
  • Time complexity: O(n * L^2) with memoization, where n is number of words and L is max length.
  • Alternative approach: dynamic programming or trie for optimization.

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