Java check all possible suffix lengths
\nclass Solution {\n    public String[] splitMessage(String message, int limit) {\n        // since message length can be at most 10^4, we cant\n        // poss
```\nclass Solution {\n    public String[] splitMessage(String message, int limit) {\n        // since message length can be at most 10^4, we cant\n        // possibly have more than 10^5-1 parts, or 5 digits in length\n        for (int numDigits = 1; numDigits <= 5; numDigits++) {\n            int maxParts = (int)Math.pow(10, numDigits) - 1;\n            \n            // determine if we can reach the end of message with the\n            // maximum number of parts, if so we have our answer\n            int idx = 0;\n            for (int part = 1; part <= maxParts; part++) {\n                int suffixLen = String.valueOf(part).length() + numDigits + 3;\n                idx += limit - suffixLen;\n                \n                if (idx >= message.length()) {\n                    // System.out.println(part);\n                    return createOutput(message, limit, part);\n                }\n            }\n        }\n        \n        return new String[0];\n    }\n    \n    private String[] createOutput(String message, int limit, int numParts) {\n        String[] output = new String[numParts];\n        int idx = 0;\n        \n        for (int i = 1; i <= numParts; i++) {\n            String suffix = "<" + i + "/" + numParts + ">";\n            int contentLen = limit - suffix.length();\n            \n            // be sure to handle last part being shorter than limit\n            int end = Math.min(idx + contentLen, message.length());\n            \n            output[i - 1] = message.substring(idx, end) + suffix;\n            idx += contentLen;\n        }\n        \n        return output;\n    }\n}\n```
[]