EASY TO UNDERSTAND || SIMPLE JAVA CODE
\nclass Solution {\n    public String digitSum(String s, int k) {\n        \n        \n        while(s.length()>k){\n            String temp="",sub;\n          
```\nclass Solution {\n    public String digitSum(String s, int k) {\n        \n        \n        while(s.length()>k){\n            String temp="",sub;\n            \n            for(int i=0;i<s.length();){\n                if(i<s.length()+1 && i+k>=s.length()){\n                     sub=s.substring(i);\n                    i+=sub.length();\n                }else{\n                     sub=s.substring(i,i+k);\n                    i+=k;\n                }\n                int count=0;\n                for(char c:sub.toCharArray())count+=c-\'0\';\n                temp+=count+"";\n            }\n            \n            s=temp;\n           \n            \n            \n        }\n        return s;\n        \n        \n    }\n}\n```
[]