Brute Force O(n). Just a Simple Trick.✅✅
Intuition\n Describe your first thoughts on how to solve this problem. \nObservation1:\nWhen you observe every suffix will be minimum of length 5. How?\n =>  of
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nObservation1:\nWhen you observe every suffix will be minimum of length 5. How?\n<a/b> => </> of length 3 + single_digit_a + single_digit_b.\nSo if your given limit is <=5 then return [].\n\nObservation2:\nWe need to find the no_of_digits in given range from [1,max_part].\nThis is the mathematical part.\nThere are 9 single digit numbers[1,9]\nThere are 90 two digit numbers [10,99]\nThere are 900 three digit numbers [100,999]\nThere are 9000 four digit numbers [1000,9999]\n.........\nUse this concept the calculate number of digits.\n# Approach\n<!-- Describe your approach to solving the problem. -->\nRun for loop from range(math.ceil(n/limit),some_max_number).\nCalulate the total lenght of op string if we take i parts.\nI break down finding this into 4 parts.\ntotal_length=<a_length/b_length>+sum(given_string)\nb_length=len(str(i))\na_length is calculate by using the technique above.\nevery part has 3 lenth i.e; "</>"\nno check if math.ceil(total_length/limit)<= i\nIf true add releavent characters to op.\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(n)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(n)\n# Code\n```\nclass Solution:\n\n    def splitMessage(self, message: str, limit: int) -> List[str]:\n        if limit<=5:\n            return []\n\n        n=len(message)\n        \n        def calculate(val):\n            op=0\n            if val>9:\n                op+=9\n            elif val<=9:\n                op+=val\n            if val>99:\n                op+=(90*2)\n            elif 10<=val<=99:\n                digits=val-10+1\n                print(digits)\n                op+=(digits*2)\n            if val>999:\n                op+=(900*3)\n            elif 100<=val<=999:\n                digits=val-100+1\n                op+=(digits*3)\n            if val>10000:\n                op+=(9000*4)\n            elif 1000<=val<=9999:\n                digits=val-1000+1\n                op+=(digits*4)\n            return op\n\n        #print(calculate(40))\n        op=[]\n        \n        for no_of_parts in range(math.ceil(n/limit),10000):\n            b_length=len(str(no_of_parts))*no_of_parts\n            brackets=3*no_of_parts\n            a_length=calculate(no_of_parts)\n\n            total=n+a_length+brackets+b_length\n\n            if math.ceil(total/limit)==no_of_parts:\n                #print(no_of_parts)\n                \n                i=0\n                present_part=1\n                while(i<n):\n                    #print(op)\n                    already_taken=(3+len(str(present_part))+len(str(no_of_parts)))\n                    remaining=limit-already_taken\n                    #print(remaining)\n                    present_string=""\n                    while(i<n and remaining>0):\n                        present_string+=message[i]\n                        i+=1\n                        remaining-=1\n                    present_string+=("<"+str(present_part)+"/"+str(no_of_parts)+">")\n                    op.append(present_string)\n                    present_part+=1\n                break\n\n        return op\n```
['Math', 'Python3']