Java Easy to Understand Code
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(n log n)\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 {\n    public String[] splitMessage(String message, int limit) {\n        \n        int low = 1, high = message.length();\n        int result = Integer.MAX_VALUE;\n\n        while( low<=high ) {\n            int mid = low + (high-low)/2;\n\n            int value = checkValidity(message, limit, mid); \n            // System.out.println(mid+" "+value);\n            if(value == 0) {\n                result = Math.min(result, mid);\n                high = mid - 1;\n                low = 1;\n            }\n            else if( value == -1 ) high = mid - 1;\n            else low = mid + 1;\n        }\n        // System.out.println(result);\n\n        if( result == Integer.MAX_VALUE) return new String[0];\n        else return getFormattedStrings(message, limit, result);\n    }\n\n    private int checkValidity(String message, int limit, int k) {\n\n        int idx = 0;\n        for(int i=1; i<=k; i++) {\n\n            if( idx >= message.length() ) return -1;\n            String format = "<"+i+"/"+k+">";\n            int left = limit - format.length();\n\n            if( left <= 0 ) return -1;\n\n            idx += left;\n\n\n        }\n\n        if( idx < message.length()) return 1;\n\n        return 0;\n    }\n\n    private String[] getFormattedStrings(String message, int limit, int k) {\n        String [] result = new String[k];\n\n        int idx = 0;\n        for(int i=1; i<=k; i++) {\n            String format = "<"+i+"/"+k+">";\n            int diff = limit-format.length();\n            \n            if( idx+diff > message.length() ) result[i-1] = message.substring(idx)+format;\n            else result[i-1] = message.substring(idx, idx+diff)+format;\n\n            idx += diff;\n        }\n        return result;   \n    }\n}\n```
['Java']