Microsoft | Phone | Split string with limit
Anonymous User
1996

Split a string into substrings. Each substring should be no longer than the given limit. The input string contains English letters and spaces only.
Do not break a word into two sub strings. Remove all spaces in the beginning or end of every sub string.

Extend: append notation such as " (1 of 12)" and strings are not longer than the limit even after the notation.

Length limit: 39. Input: The quick brown fox jumps over a lazy dogThe quick brown fox jumps over a lazy dogThe quick brown fox jumps over a lazy dogThe quick brown fox jumps over a lazy dogThe quick brown fox jumps over a lazy dogThe quick brown fox jumps over a lazy dogThe quick brown fox jumps over a lazy dogThe quick brown fox jumps over a lazy dogThe quick brown fox jumps over a lazy dog

Result should be:
The quick brown fox jumps (1 of 14)
over a lazy dogThe quick (2 of 14)
brown fox jumps over a lazy (3 of 14)
dogThe quick brown fox jumps (4 of 14)
over a lazy dogThe quick (5 of 14)
brown fox jumps over a lazy (6 of 14)
dogThe quick brown fox jumps (7 of 14)
over a lazy dogThe quick (8 of 14)
brown fox jumps over a lazy (9 of 14)
dogThe quick brown fox jumps (10 of 14)
over a lazy dogThe quick (11 of 14)
brown fox jumps over a lazy (12 of 14)
dogThe quick brown fox jumps (13 of 14)
over a lazy dog (14 of 14)

Comments (4)