My Blog List

[Leetcode Solution] Word Break

Analysis

  • Using dynamic programming
  • Let f[i] denote if substring which from 0 to i could be segmented into dictionary words
  • f[i]==true iff there is k that f[k-1]==true && substring from k to i is a dictionary word

Note

  • vector constructor
    • vector(size, value) RIGHT!
    • vector(value, size) WRONG!
  • string constructor
    • string(string,start position, size)

Code