How about this input ?


  • 0
    B

    when I debug my program, there is always LTE, and I find it is because this string :

    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab

    notice that the last character is "b", then this sentence can't break into words in dict, after check the validation of word break use WordBreakI, the LTE fixed.

    but does there any other good solution for this string ?

    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

    which is a valid sentence and can be breaked ? I have no good idea on it, the DP taking so much time to backtrace.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.