Python3 Intuitive: Assume Message Count < 9, Update as Needed O(n) O(n)
Intuition\nAs others noted, problem reduces to finding total number of messages. Let ml=message length. While ml>0, assume total number of messages is <9, now y
# Intuition\nAs others noted, problem reduces to finding total number of messages. Let ml=message length. While ml>0, assume total number of messages is <9, now you know how big each message is. After processing message 9, if you still have message length to send, then assume total number of messages <99 instead, and keep sending. Since the suffix for previous messages is off (was /9, now needs to be /99), we sent one (1) too many characters of content in every message we\'ve done so far, so we increase the message length to send (ml) by num messages sent so far. It is impossible when the suffix length >= message length.\n\nThe O(n) from processing each message in the first step doesn\'t matter since we have to do O(n) to create the messages anyway.\n\n# Code\n```python3 []\nclass Solution:\n    def splitMessage(self, m: str, pl: int) -> List[str]:\n        # guess: O(n), O(n)\n\n        # for the a in <a/b>, there are \n        # 9-0 = 9 parts of length 1,\n        # 99-9 = 90 parts of length 2\n        # 999-99 = 900 parts of length 3\n        # 9999-999 = 9000 parts of length 4\n        # ..\n        ml=len(m)\n        np,npl=0,0\n        while 0<ml:\n            npl+=1\n            ml+=np \n            # stop if can\'t make progress by sending message\n            if pl<=3+2*npl:\n                return []\n            for _ in range(9*(10**(npl-1))):\n                if ml<=0:\n                    break\n                np+=1\n                ml-=(pl-(3+2*npl))\n        ml=len(m)\n        i,pi=0,1\n        out=[]\n        while pi<=np:\n            tag=f"<{pi}/{np}>"\n            out.append(m[i:i+pl-len(tag)]+tag)\n            pi+=1\n            i+=(pl-len(tag))\n        return out\n```
['Python3']