Easy Java Solution!
Intuition\n Describe your first thoughts on how to solve this problem. \nThe problem requires us to split a message into multiple parts where each part ends wit
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe problem requires us to split a message into multiple parts where each part ends with a suffix indicating its position. The length of each part including the suffix should not exceed a given limit, and we aim to use as few parts as possible.\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. Initial Setup: Calculate the total length of the message and initialize variables for the number of parts (b) and the total length of the suffixes (aLength).\n2. Determine Number of Parts (b):\n    - Use a while loop to determine the minimum number of parts needed such that the total length of the parts including their suffixes does not exceed the allowed limit.\n    - In each iteration, check if the suffix length itself exceeds the limit. If so, return an empty array as it\'s impossible to split the message as required.\n    - Update the cumulative length of the indices (aLength) as b increases.\n3. Create Resulting Parts:\n    - Initialize an array to store the resulting parts.\n    - Iterate over the number of parts and form each part by taking the appropriate substring from the message and appending the suffix.\n    - Ensure that the combined length of the message portion and the suffix does not exceed the limit.\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n    - Calculating the number of parts involves a loop that depends on the number of parts, which can be approximated as O(b).\n    - Creating the resulting parts involves another loop over the number of parts, which is also O(b).\n    - Overall, the time complexity is O(b), where b is the number of parts.\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n    - The space used to store the resulting parts is O(b).\n    - Additional space is used for storing substrings and suffixes, which is linear in relation to the size of the message.\n    - Overall, the space complexity is O(n), where n is the length of the message.\n# Code\n```\nclass Solution {\n    public String[] splitMessage(String message, int limit) {\n        int n = message.length();\n        int part = 1;\n        int alen = 1;\n\n        // Determine the number of parts (b)\n        while(part * limit < (String.valueOf(part).length() + 3) * part + n + alen) {\n            if(String.valueOf(part).length() * 2 + 3 >= limit)\n                return new String[]{};\n            alen += String.valueOf(++part).length();\n        }\n\n        int b = part;\n        String[] ans = new String[b];\n\n        // Create resulting parts\n        for(int a = 1, i = 0; a <= b; a++) {\n            int idx = limit - (3 + String.valueOf(a).length() + String.valueOf(b).length());\n            ans[a - 1] = message.substring(i, Math.min(i + idx, message.length())) + \n            "<" + String.valueOf(a) + "/" + String.valueOf(b) + ">";\n            i += idx;\n        }\n\n        return ans;\n    }\n}\n```
['Math', 'Java']