Binary search solution
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\nfindLen(9, 8) > findLen(10, 8). Need to define the right bounder of binar
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nfindLen(9, 8) > findLen(10, 8). Need to define the right bounder of binary search in {9, 99, 999, 999} first.\n\n# Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(n)\n\n# Code\n```\nclass Solution {\n    public String[] splitMessage(String message, int limit) {\n        int len = message.length();\n        int part = findPart(len, limit);\n        if(part == -1) return new String[0];\n        int partIndex = 1;\n        StringBuilder sb = new StringBuilder();\n        String[] res = new String[part];\n        for(int i = 0; i < len; i ++) {\n            sb.append(message.charAt(i));\n            int suffixLen = 3 + countDigit(part) + countDigit(partIndex);\n            if(sb.length() + suffixLen == limit || i == len - 1) {\n                sb.append("<" + partIndex + "/" + part + ">");\n                res[partIndex - 1] = sb.toString();\n                partIndex++;\n                sb = new StringBuilder();\n            }\n        }\n        return res;\n    }\n\n    private int findPart(int len, int limit) { \n        int[] partSection = {9, 99, 999, 9999};\n        int left = 0;\n        int index = 0;\n        while(index <= 3 && getLen(partSection[index], limit) < len) {\n            index++;\n        }\n        if(index > 3) return -1;\n        int right = partSection[index];\n        while(left <= right) {\n            int mid = left + (right - left) / 2;\n            if(getLen(mid, limit) < len) left = mid + 1;\n            else right = mid - 1;\n        }\n        return left;\n    }\n\n    private int getLen(int part, int limit) {\n        int res = part * (limit - 3 - countDigit(part));\n        int cur = 1;\n        int digit = 1;\n        while(cur * 10 < part) {\n            res -= digit * cur * 9;\n            cur *= 10;\n            digit++;\n        }\n        res -= (part - cur + 1) * digit;\n        return res;\n    }\n\n    private int countDigit(int num) {\n        return Integer.toString(num).length();\n    }\n}\n```
['Java']