Lengthy but easy approach (Java)
\n# Approach\nLogical one but somewhat long-\nFirst I checked if the string contains the exact number of characters which can be divided into k pairs. If the ch
\n# Approach\nLogical one but somewhat long-\nFirst I checked if the string contains the exact number of characters which can be divided into k pairs. If the characters are more then the fill string is added number of times so that string can be divided into k pairs.Then the pairs are added to arraylist and returned as array.\n\n# Complexity\nRuntime: 5 ms\nMemory: 41.3 MB\n\n# Code\n```\nclass Solution {\n    public String[] divideString(String s, int k, char fill) {\n        \n        if(s.length()%k!=0){\n            int c2=k;\n            int hm=0;\n            for(int i=0;i<s.length();i+=k){\n                if(i>hm){\n                    hm=i;\n                }\n            }\n            int fk=(hm+k)-(hm+1);\n            List<String> lst=new ArrayList<>();\n            StringBuilder ss=new StringBuilder(s);\n            for(int j=0;j<fk;j++){\n                ss.append(fill);\n            }    \n            String fi=ss.toString();\n            System.out.println(fi);\n            for(int i=0;i<fi.length();i+=k){\n                if(c2<=fi.length()){\n                    StringBuilder sb=new StringBuilder();\n                    sb.append(fi.substring(i,c2));\n                    lst.add(sb.toString());\n                    c2+=k;\n                }\n                \n            }\n            String[] arr = new String[lst.size()]; \n  \n            // ArrayList to Array Conversion \n            for (int i = 0; i < lst.size(); i++) arr[i] = lst.get(i); \n            return arr;\n        }\n        else{\n            int c2=k;\n            List<String> lst=new ArrayList<>();\n            \n            for(int i=0;i<s.length();i+=k){\n                if(c2<=s.length()){\n                    StringBuilder sb=new StringBuilder();\n                    sb.append(s.substring(i,c2));\n                    lst.add(sb.toString());\n                    c2+=k;\n                }\n                \n            }\n            String[] arr = new String[lst.size()]; \n  \n            // ArrayList to Array Conversion \n            for (int i = 0; i < lst.size(); i++) arr[i] = lst.get(i); \n            return arr;\n        }\n        \n    }\n}\n```
['String', 'Java']