方法:递归模拟
class Solution {public String digitSum(String s, int k) {if (s.length() <= k) return s;String temp = "";for (int i = 0; i < s.length(); i += k) {int x = 0;for (int j = i; j < i + k && j < s.length(); j++) {x += s.charAt(j) - '0';}temp += x;}return digitSum(temp, k);}
}