Word Break

Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words.

For example, given

s = "myinterviewtrainer",
dict = ["trainer", "my", "interview"].

Return 1 ( corresponding to true ) because "myinterviewtrainer" can be segmented as "my interview trainer".

Return 0 / 1 ( 0 for false, 1 for true ) for this problem

Interview Code Editor
Hints
  • Solution Approach
  • Complete Solution
1509 successful submissions.
Asked In:
  • IBM
  • Google
Click here to jump start your coding interview preparation