You are given a line of strings, each words are seperated by spaces. You can only insert new lines in the 5-10th column of your string. Your goal is to maximize the number of lines that end with the character x. How would you do this for example.
Edit: The words can end with any character, Say you are given the text
abcdfg cdx abcdx abcdefg aa ggffx ax
then the way to display them would be
column:
1234567890
abcdfg cdx
abcdx
abcdefg
aa ggfx
ax
this would maximize the result because it has 4 lines that end with x
I feel the real problem of this question is how do we brake if it doesn't end with x and it is at a position that can brake.
Observe
abcdefg
aa ggfx
ax
If aa was on the 1st line with abcdefg then we will only be able to have 1 more line of x because ggfx can't brake right away. As a result ggfx ax would be on the same line