Word break problem from gfg

I’m attaching a link to the article

Can you tell me inside wordBreakUtil when we are caliing the function recursively what actually we are doing?

Hey @div_yanshu07
Say dictionary is [ab,cd]
Now u had string abcdab

U found ab now in next call we are sending remaining string cdab
along with its length n-i i.e 4
along with formed string so far i.e ab
so wordBreakUtil(“cdab”,4,"ab ")

Why are we sending the string formed so far? So, that we can concatenate??
If yes please give example!

Yup since there can be multiple outputs like see this one
Consider the following dictionary
{ i, sam, sung, samsung}
Input: “isamsung”
Output: i sam sung
i samsung

Do a dry run on this and you will understand everything properly

https://practice.geeksforgeeks.org/problems/word-break-part-2/0#

Yes, now my code is generating all the possible options but it doesn’t match with the output.
How am I supposed to generate those brackets

Hey @div_yanshu07

        // cout<<"(";removed
        for(auto it: v)
        {
            cout<<"("<<it<<")";//updated
        }
        // cout<<")";removed

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.