Binary search
Approach\n Describe your approach to solving the problem. \n\nBinary search the number of parts\n\n# Complexity\n- Time complexity: O(log n + n), binary search 
# Approach\n<!-- Describe your approach to solving the problem. -->\n\nBinary search the number of parts\n\n# Complexity\n- Time complexity: O(log n + n), binary search + answer construction\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    int isLargerOrFit(int n, int sz, int limit) {\n        string b = to_string(sz);\n        int b_sz = b.size();\n        if (2 * b_sz + 3 > limit) return true;\n        int total = (limit - b_sz - 3) * (sz - 1);\n        if (sz <= 10) total -= (sz - 1);\n        else if (sz <= 100) total -= 9 + 2 * (sz - 10);\n        else if (sz <= 1000) total -= 9 + 2 * 90 + 3 * (sz - 100);\n        else if (sz <= 10000) total -= 9 + 2 * 90 + 3 * 900 + 4 * (sz - 1000);\n        int res = n - total;    // residual or remained characters\n        if (res >= 0 && res + 2 * b_sz + 3 <= limit) {  // fit\n            return 0;\n        } else if (res < 0) {   // larger\n            return 1;\n        }\n        return -1;  // smaller\n    }\n    \n    vector<string> splitMessage(string message, int limit) {\n        if (limit <= 5) return vector<string>();    // unrealistic limit\n        int n = message.size();\n        int low = 0, high = n + 1;\n        while (low + 1 < high) {\n            int mid = low + (high - low) / 2;\n            if (isLargerOrFit(n, mid, limit) >= 0) high = mid;\n            else low = mid;\n        }\n        if (isLargerOrFit(n, high, limit) == 1) return vector<string>();\n        vector<string> ans(high);\n        string b = to_string(high);\n        for (int a = 1, l = 0; a <= high; a++) {\n            string suffix = "<" + to_string(a) + "/" + b + ">";\n            int sz = limit - suffix.size();\n            ans[a - 1] += message.substr(l, sz) + suffix;\n            l += sz;\n        }\n        return ans;\n    }\n};\n```
['C++']