Split Text into Minimum Suffixed SMS Messages
Problem statement
Split every text character in order into the minimum number y of messages. Message x ends with suffix <x/y>, which counts toward limit.
Every nonlast message must have total length exactly limit; the last may be shorter. Each message contains at least one text character. Return the first feasible split, or an empty array.
Function
splitSms(text: String, limit: int) → String[]Examples
Example 1
text = "abcdefghij"limit = 7return = ["ab<1/5>","cd<2/5>","ef<3/5>","gh<4/5>","ij<5/5>"]Five messages are the first total count with enough capacity.
Example 2
text = "abc"limit = 10return = ["abc<1/1>"]One message fits.
Constraints
1 <= text.length <= 100001 <= limit <= 10000