✅  Most Descriptive Solution So Far
\u2705 It surprises me how posts with absolutely no explanation receive so many upvotes!!\n\n# Code\nJava []\nclass Solution {\n    // returns the number of cha
### \u2705 It surprises me how posts with absolutely no explanation receive so many upvotes!!\n\n# Code\n``` Java []\nclass Solution {\n    // returns the number of characters in an integer\n    int charLen(int value) {\n        int len = 0;\n        while(value!=0) {\n            len++;\n            value /=10;\n        }\n        return len;\n    }\n    // segments = k\n    int checkValidity(String message, int limit, int segments) {\n        int charLenSoFar = 0;\n        int msgLen = message.length();\n        for(int i=1; i<=segments; i++) {\n            // if total character length we have collected so far\n            // increases the message length, then we have taken too many segments\n            // We need to look on the left, return -1\n            if(charLenSoFar >= msgLen) {\n                return -1;\n            }\n            int formatLen = 3 + charLen(i) + charLen(segments); // "<" + i + "/" + segments + ">"\n            int remLen = limit - formatLen;\n            // if the remaining length of a chunk is less than or eq 0,\n            // then we won\'t be able to add any character to it\n            if(remLen <= 0) {\n                return -1;\n            }\n            // we can take remLen (remaining length) characters from the message string\n            charLenSoFar += remLen;\n        }\n\n        // if characters we were able to collect so far is less than the message length,\n        // we need to increase our segments, so, look on the right side, return 1\n        if(charLenSoFar < msgLen) {\n            return 1;\n        }\n\n        // we were able to confine all the characters of message\n        // using this segments. So, this is a happy case and possible answer.\n        return 0;\n    }\n\n    public String[] splitMessage(String message, int limit) {\n        int left = 1;\n        int right = message.length();\n        int segments = Integer.MAX_VALUE;\n\n        while(left <= right) {\n            int mid = left + (right-left)/2;\n\n            int segmentValidity = checkValidity(message, limit, mid);\n            if(segmentValidity == 0) {\n                segments = Math.min(segments, mid);\n                right = mid - 1;\n                left = 1;\n            }\n            // we need to look on the left side\n            else if(segmentValidity == -1) {\n                right = mid - 1;\n            }\n            // we need to look on the right side\n            else {\n                left = mid + 1;\n            }\n        }\n        // if we never found any happy case, there\'s no answer\n        if(segments == Integer.MAX_VALUE) {\n            return new String[0];\n        }\n        else {\n            // construct the string with minimum segments we were able to determine\n            return getFormattedStrings(message, limit, segments);\n        }\n    }\n\n    // segments = k\n    String[] getFormattedStrings(String message, int limit, int segments) {\n        String[] res = new String[segments];\n        int msgLen = message.length();\n        int charLenSoFar = 0;\n\n        for(int i=1; i<=segments; i++) {\n            String format = "<" + i + "/" + segments + ">";\n            int remaining = limit - format.length();\n\n            int startIdx = charLenSoFar;\n            int endIdx = charLenSoFar + remaining;\n            // we don\'t want it to go out of bound..\n            endIdx = Math.min(msgLen, endIdx);\n\n            res[i-1] = message.substring(startIdx, endIdx) + format;\n\n            // update charLenSoFar (characters so far seen) value \n            // as we were able to acquire remaining size of characters\n            charLenSoFar += remaining;\n        }\n\n        return res;\n    }\n}\n```
['String', 'Binary Search', 'Java']