Flipkart: Map each word to every way it can be built from other words in the list
Problem. You get a list of words. Return a map whose keys are the words that can be made by joining two or more other words from the same list. Each value lists every combination of words that forms that key.
Example. Input: happy, rise, for, set, sunrise, sun, su, nset, sunset, mind, happymind, n, rise, happysunrise.
Part of the expected output:
- happymind -> [happy, mind]
- sunrise -> [su, n, rise] and [sun, rise]
The word list contains duplicates (rise appears twice), and a single word can have several valid splits. You need all of them, not just one.
Expectation. Any working implementation was accepted. It was the third question in a problem-solving round that also covered the rightmost node on the last level of a complete binary tree and the smallest missing non-negative number. The post gave no constraints or follow-ups for this one.
Comments 0
No comments yet. Ask the author something, or add what happened in your own round.