This is basically a dublicate of:
How to split a string into words. Ex: "stringintowords" -> "String Into Words"?
neverthelees, I have in my use a function like: public int Word(x) {code}
, where for a string x,it will return an integer (+ve or -ve), and that integer will be an indication of how good or bad that partitioning is for the specific word. I should return the combination that gives the maximum number.
What I thought of doing for this is to create a table(i,j) , where i and j have length of the word, and fill out the table in tern like:
for i = 1 to n
for j=i to n do
word(subset of x i to j)
and fill out the table, nevertheless, how on earth will I ever be able to retrieve the optimal solution (in a recursive way?)
any help appreciated.
EDIT: The optimal path is the one with the highest sum of word(x) function, i.e. if we have
a path(1,3)=10 , (3,6)=20, (6,7)=1 , and
a path (1,1)=0 , (2,5)=12, (5,7)=-1
then the sum of the 1st path > 2nd
EDIT2: I would like every one to know that this question has been answered by me after long hours of work , nevermind for not getting the solution, getting it yourself is always best i guess:P
cheers!:)