17.7 bedbathandbeyond word breaking. What is the valid solution output?

#1

Hi ,
I have a question on bedbathandbeyond word breaking problem. From the 2nd test case expected output, the valid solution seems to be the minimum splits between words. I think “pp”, “pp”,“pppp” or “pppp”, “pp”, “pp” or even “ppp”,“pp”,“ppp” could also be correct. Is the problem needed to be solved with minimum breaks of words?

Test FAILED ( 2/42) [ 7 us]
domain: pppppppp
dictionary: [“pppp”, “ppp”, “pp”]
expected: [pppp, pppp]
result: [pppp, pp, pp]

Would be nice if the problem statement is clarified.

Thank you

0 Likes

#2

Hi @vesper_zhao,

I think the test data definitely needs some update. Your solution is definitely a valid one so it means we shall modify the checker for this problem. Really appreciate for your input, and we will fix the checker then.

0 Likes

#3

@tsunghsienlee

From the original post, it looks like, if the domain contains a subset of the words in the dictionary, the solution should return one such subset. Is that correct?

0 Likes

#4

Yes, the problem was that there are several compositions that might be able to reconstruct the original domain so it is causing problem for other acceptable answer.

I was patched this one few days ago with new checker.

0 Likes

#5

@tsunghsienlee

Ok. Thanks.
Originally, I thought the problem was saying that the domain had to match at least one occurrence of every word in the dictionary. I didn’t realize that it’s ok to match just a subset of words in the dictionary.

0 Likes