[Java] 0ms + EASY explanations
\nclass Solution {\n    /** Algorithm\n         1. While s is longer than k, try to add its digits into a string builder stb\n         2. Loop in windows of k s
```\nclass Solution {\n    /** Algorithm\n         1. While s is longer than k, try to add its digits into a string builder stb\n         2. Loop in windows of k size and continue ONLY if current index  < s.length().\n            (meaning current expanding window is still shorter than s.length())\n            EG: "123456789", k = 4. window1 : "1,2,3,4", window2 = "5,6,7,8"\n         3. In an inner loop, loop with j from i to i+ k; stopping at i + k OR when j reaches s.length() -1 \n             Add digits to a temp int and add it to string builder   \n         4. Make s point to the string value of the string builder.\n         5. Return s.\n     */\n    public String digitSum(String s, int k) {\n        StringBuilder stb = new StringBuilder();\n        int temp = 0;\n        while(s.length() > k) {\n            stb.setLength(0);\n            for(int i = 0; i < s.length(); i += k) {\n                temp = 0;\n                for(int j = i; j < i + k && j < s.length(); j++) {\n                    temp += s.charAt(j) - \'0\';\n                }\n                stb.append(temp);\n            }\n            s = stb.toString();\n        }\n        return s;\n    }\n}\n```
['Java']