Interview Question

Software Developer Interview

Given an input string and a dictionary of words, segment

  the input string into a space-separated sequence of dictionary words if possible. For example, if the input string is "applepie" and the dictionary is a standard set of English words, then we would return the string "apple pie" as output.

Interview Answer

1 Answer


Have a loop that that checks if the dictionary contains "a", if not, check if it contains "ap" and so on... when found in the dictionary, substring the input string starting from the character after the matched word.

Anonymous on Mar 16, 2013

Add Answers or Comments

To comment on this Question, Sign In with Facebook or Sign Up