Confused by this questions!

  • 2

    For the test case:

    ["a b","c d"]

    The output is generated by all those accepted solutions described here.

    I think it violates the following description:

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

    We notes that the last line "c d" has a space inserted!

    If the last line means the last line of input, what do you mean by no extra space is inserted between words , given that every line of input String[] words has only one word?

    What's the right answer for this test case?

  • 0

    The definition of justification does not stop you from correctly separating words by spaces (as per normal English Grammar). If a line (with correctly inserted spaces) happens to be exactly MaxWidth characters long, then that is simply a happy coincidence, and not a violation of anything.

    The point is that on the last line, you do not insert any extra spaces.

    Hope this helps.

Log in to reply

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