EASY || Beats 85%
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \nFirst we divide the tex
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nFirst we divide the text into words with max limit "LIMIT - 5" because ["<_/_>" (5 min characters)] then we will see how many characters will the suffix take acc to ans size(WE WILL DO IT TWICE BEACUSE IN SOME CASE THE ANS SIZE MAY CHANGE FROM 2 DIGIT TO 3 DIGIT).\n\nAnd in the last we put the suffix\n\n# Complexity\n- Time complexity:O(N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    vector<string> splitMessage(string m, int limit) {\n        if(limit <= 5){\n            return {};\n        }\n        vector<string> ans;\n        int n = m.length(), i = 0;\n\n        while(i < n){\n            int l = min(limit - 5, n - i);\n            ans.push_back(m.substr(i, l));\n            i = i + limit - 5;\n        }\n\n        int s = 1, place = log10(ans.size()) + 1;\n        i = 0;\n        ans.clear();\n        while(i < n){\n            int cntr = limit - 4 - place;\n            int c = log10(s);\n            cntr -= c;\n            if(cntr <= 0){\n                return {};\n            }\n            int l = min(cntr, n - i);\n            ans.push_back(m.substr(i, l));\n            i = i + cntr;\n            s++;\n        }\n\n        int p = log10(ans.size()) + 1;\n        if(p != place){\n            s = 1;\n            place = p;\n            i = 0;\n            ans.clear();\n            while (i < n)\n            {\n                int cntr = limit - 4 - place;\n                int c = log10(s);\n                cntr -= c;\n                int l = min(cntr, n - i);\n                if(cntr <= 0){\n                    return {};\n                }\n                ans.push_back(m.substr(i, l));\n                i = i + cntr;\n                s++;\n            }\n        }\n\n        n = ans.size();\n        int t = log10(n) + 1;\n        int maxi_ = (2 * t) + 3;\n        if(maxi_ >= limit){\n            return {};\n        }\n        string si = to_string(n);\n        string suf = "/" + si + ">";\n\n        for(int i = 0; i < n; i++){\n            string t = "<" + to_string(i + 1) + suf;\n            ans[i] = ans[i] + t;\n        }\n\n        return ans;\n    }\n};\n```
['C++']