Skip to content

Commit 96ccf6e

Browse files
committed
Runtime: 6 ms (Top 32.40%) | Memory: 40.8 MB (Top 89.31%)
1 parent 97e1fbb commit 96ccf6e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Runtime: 6 ms (Top 32.40%) | Memory: 40.8 MB (Top 89.31%)
2+
class Solution {
3+
public String digitSum(String s, int k) {
4+
while(s.length() > k) s = gen(s,k);
5+
return s;
6+
}
7+
public String gen(String s,int k){
8+
String res = "";
9+
for(int i=0;i < s.length();){
10+
int count = 0,num=0;
11+
while(i < s.length() && count++ < k) num += Character.getNumericValue(s.charAt(i++));
12+
res+=num;
13+
}
14+
return res;
15+
}
16+
}

0 commit comments

Comments
 (0)