You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"Extra spaces between words should be distributed as evenly as possible." Should be "Extra spaces between words IN EACH LINE should be distributed as evenly as possible."
4
+
So the problem in short is:
5
+
1. Every line should have as many as word as possible. But they should be separate by space or spaces.
6
+
2. Mid align all the line. Except the last line and the lines with one word.
7
+
3. For mid align, distribute space evenly, if there are extra spaces, it should be located left. For example 5 spaces distribute to 2 places, it should be 3 2, not 2 3. 7 spaces distribute to 3 places, it should be 3 2 2, not 2 3 2, not 2 2 3.
8
+
9
+
Time: O(N), N is the number of words.
10
+
Space: O(W), W is maxWidth for keeping strings in currLine. Can further reduce to O(1) using only index.
0 commit comments