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
Coding & Algorithms
Software Engineer
Amazon
July 5, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Hard

3

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
String Manipulation
Data Structures
Algorithm Efficiency
Edge Cases
Testing
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. 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 Problems
Sample 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
  1. Create a set of all words for O(1) lookups.
  2. 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....

Submit Your Answer
Markdown supported