Find Two-Word Compound Words
Last updated: July 5, 2026
Quick Overview
The candidate is asked to write a function that identifies all two-word compound words from a given list of words.
Amazon
July 5, 20263
0
34 solved
The candidate is asked to write a function that identifies all two-word compound words from a given list of words.
This question is typically asked during the technical screen round at Amazon to assess a candidate's problem-solving skills and coding proficiency. The interviewer evaluates the candidate's ability to think critically, implement algorithms efficiently, and handle edge cases while writing clean, maintainable code.
What the Interviewer Expects
- Clearly define the problem and requirements.
- Outline a logical approach to solve the problem.
- Implement a working solution with appropriate data structures.
- Discuss the time and space complexity of the solution.
- Handle edge cases and provide test cases.
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you optimize your solution for larger datasets?
- Can you explain the choice of data structures used in your solution?
- What would you do differently if the input list could contain non-unique words?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Approach
To solve the problem of finding two-word compound words, we need to iterate through the list of words and check if any two words can be concatenated to form another word in the list. A straightforward...
Algorithm
- Create a set of all words for O(1) lookups.
- Loop through each word in the list:
- For each word, split it into two parts at every possible index.
- Check if both parts exist in the set. 3....