Java 100% faster | 96% memory solution
Code\n\nclass Solution {\n    public String digitSum(String s, int k) {\n        StringBuilder sb = new StringBuilder();\n        String intermediate = s;\n    
# Code\n```\nclass Solution {\n    public String digitSum(String s, int k) {\n        StringBuilder sb = new StringBuilder();\n        String intermediate = s;\n        int interInt = 0;\n        while (intermediate.length() > k) {\n            for (int i = 0; i < intermediate.length(); i += k) {\n                for (int j = i; j < i + k && j < intermediate.length(); j++) {\n                    interInt += intermediate.charAt(j) - \'0\';\n                }\n                sb.append(interInt);\n                interInt = 0;\n            }\n            intermediate = sb.toString();\n            sb.setLength(0);\n        }\n        return intermediate;\n    }\n}\n```
['Java']