Simple java code
\n# Complexity\n- \n\n# Code\n\nclass Solution {\n    public String[] divideString(String s, int k, char fill) {\n        int n=s.length();\n        int extra=0
\n# Complexity\n- \n![image.png](https://assets.leetcode.com/users/images/8789b265-da38-45a0-af0e-7faa2293c03d_1703940194.208272.png)\n# Code\n```\nclass Solution {\n    public String[] divideString(String s, int k, char fill) {\n        int n=s.length();\n        int extra=0;\n        int flag=0;\n        if(n%k!=0){\n            extra=n%k;\n            extra=k-extra;\n            flag=1;\n        }\n        int len=(n/k)+flag;\n        String arr[]=new String[len];\n        if(k>=n){\n            if(k==n){\n                arr[0]=s;\n            }\n            else{\n                for(int l=n;l<k;l++){\n                    s=s+fill;\n                }\n                arr[0]=s;\n            }\n            return arr;\n        }\n        int j=0;\n        int i=0;\n        for(i=0;i+k<=n;i+=k){\n            arr[j++]=s.substring(i,i+k);\n        }\n        if(j==len-1){\n            String s2=s.substring(i,n);\n            for(int l=0;l<extra;l++){\n                s2=s2+fill;\n            }\n            arr[j]=s2;\n        }\n        return arr;\n    }\n}\n```
['Java']