Confusion on dividing spaces...

  • 0

    Extra spaces between words should be distributed as evenly as
    possible. If the number of spaces on a line do not divide evenly
    between words, the empty slots on the left will be assigned more
    spaces than the slots on the right.

    Does this mean we should assign more spaces on left-most slot or left slots relative to the last one?
    For example we have 8 spaces and 3 slots, shall we split it into (3, 3, 2) or (4, 2, 2)? Because both seem to be evenly spited...since now we can't see test cases I don't really know which approach will pass..

  • 1

    I think (3, 3, 2) is more evenly than (4, 2, 2).

  • 0

    basically if space%slot==0 , then we can use space/slot.
    otherwise for the first space%slot SPACE, we should use space/slot+1
    for the other SPACE,we use space/slot

  • 0

    Yes. Thanks.

Log in to reply

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