Reported October 2026
Amazondynamic programming

Concatenated Words

Reported by candidates from Amazon's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Amazon OA. Under 2s to a working solution.
Founder's read

Brute force dies here. Trying every split of every word against every other word blows up fast, and Amazon reported this Concatenated Words OA in October 2026. The input is a list of words, and you return each one built from at least two shorter words in that same list. It looks like a string problem, but the real engine is dynamic programming over a hash set. If you've seen Word Break, you're most of the way there. If you blank, StealthCoder runs invisibly during the live OA as a safety net.

The problem

Return every word in words that can be formed by concatenating at least two shorter words from the same input.

Examples
Example 1
words = ["cat","cats","dog","catsdog","dogcat","rat"]
return = ["catsdog","dogcat"]
catsdog and dogcat each combine two shorter input words.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is to treat each word as its own Word Break problem, using the other input words as the dictionary. Put all words in a hash set. For each word, run a DP where dp[i] means the prefix of length i can be built from dictionary words. Check every j less than i, and if dp[j] is true and the substring j..i is in the set, mark dp[i] true. The word qualifies if dp[len] is true. The pitfall is letting a word match itself. Require at least two pieces: skip the full-length substring when j is 0, or sort by length and only add shorter words to the set. Also skip empty strings. Cost is roughly O(n * L^2) with substring hashing. If the DP slips away mid-assessment, StealthCoder is the hedge that reads the problem and hands you the structure.

The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.

If this hits your live OA

You can drill Concatenated Words cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as concatenated words. If you have time before the OA, drill that.

⏵ The honest play

You've seen the question. Make sure you actually pass Amazon's OA.

Amazon reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Concatenated Words FAQ

What's the trick to Concatenated Words?+

Reduce it to Word Break per word. Store all words in a hash set, then for each word run a prefix DP checking whether it splits into dictionary words. The only twist is that the word can't count as a single piece of itself, so you need at least two parts.

How do I stop a word from matching itself?+

Two clean ways. Sort words by length and only insert a word into the set after you test it, so the set holds shorter words only. Or in the DP, forbid the split where j is 0 and i is the full length. Either enforces the two-piece rule.

How hard is this really?+

It's a LeetCode Hard on paper, but it's Word Break run in a loop. If you can write Word Break from memory, this is a small extension. The difficulty is spotting the reduction and handling the self-match edge case, not the code volume.

What's the time complexity I should state?+

For n words with max length L, each word's DP checks O(L^2) substrings, and hashing a substring costs up to O(L). That gives about O(n * L^3) worst case, or O(n * L^2) if you bound substring cost. State it plainly and mention the hash set lookup.

Can I solve it with a trie or DFS instead?+

Yes. A trie with DFS and memoization works, and so does DFS over the hash set with a memo on start index. The DP is shorter to write and easier to debug under pressure, so pick it unless you already think in tries.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Amazon.

OA at Amazon?
Invisible during screen share
Get it