Fetching algorithms...
`dp[i]` is true if the prefix of length `i` (`s[0...i-1]`) can be segmented.
To check this, we look at all split points `j` from 0 to `i - 1`. If `dp[j]` is true (prefix `s[0...j-1]` is valid) and the suffix `s[j...i-1]` is in the dictionary, then `dp[i]` is set to true.
If we find any valid segmentation, we break early to optimize.
Initialize the word set for fast lookups and get the input string length.