I found a wrong answer in test cases


  • -1
    B

    Input: ["What","must","be","shall","be."], 12
    Output: ["What must be","shall be."]
    Expected: ["What must be","shall be. "]

    I believe my output is the right answer. The expectation is wrong.


  • -1
    N

    I agree with you, my code also return same thing.

    Here is output:

    Input:	["What","must","be","shall","be."], 12
    Output:	["What must be","shall    be."]
    Expected:	["What must be","shall be.   "]
    

    I think "shall be." is better than "shall be. "


  • 0
    K

    for the last line you should add space to the end, not in between.


  • 1
    S

    It is said

    "For the last line of text, it should be left justified and no extra space is inserted between words. "

    which means if the last line contains "shall","be." and L=12. The last line should be [shall be. (three space)] instead of [shall (three space) be.]

    I think you really have the all previous lines done, just need to deal with the last line only. Try a little bit more, bro.

    Hints: you should deal with what was left (which is the last line) separately placing the space.


Log in to reply
 

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