the fastest solution run time 97% memory 90%
\n\n\nclass Solution {\n   public static String digitSum(String s, int k) {\n\n        StringBuilder stringBuilder = new StringBuilder();\n\n        while (s.le
![image](https://assets.leetcode.com/users/images/eff66c9d-2218-4b08-b5d3-895e747b96c0_1668230310.485688.png)\n\n```\nclass Solution {\n   public static String digitSum(String s, int k) {\n\n        StringBuilder stringBuilder = new StringBuilder();\n\n        while (s.length() > k) {\n\n            for (int i = 0; i < s.length(); i+=k) {\n\n                if (i+k<=s.length())    stringBuilder.append(sum(s.substring(i, i + k)));\n                else stringBuilder.append(sum(s.substring(i)));\n            }\n\n            s = stringBuilder.toString();\n            stringBuilder = new StringBuilder();\n\n        }\n\n        return s;\n    }\n\n        public static Integer sum(String number){\n\n        int n = 0;\n\n            for (int i = 0; i < number.length(); i++) {\n                n += Integer.parseInt(number.substring(i,i+1));\n            }\n\n        return n;\n    }\n}\n```
['Java']