You are given a string s consisting of digits and an integer k.
A round can be completed if the length of s is greater than k. In a single round, perform the following consecutive actions:
Divide s into consecutive groups of size k such that the first k characters belong to the first group, the next k characters belong to the second group, and so on. The final group may contain fewer than k characters.
Replace each group with the string representation of the sum of its digits.
Concatenate all resulting strings in their original order to form the updated string s.
Repeat this process until the length of s is less than or equal to k.
Return s after completing all possible rounds.
Constraints:
s.length
k
s consists of digits only.
You are given a string s consisting of digits and an integer k.
A round can be completed if the length of s is greater than k. In a single round, perform the following consecutive actions:
Divide s into consecutive groups of size k such that the first k characters belong to the first group, the next k characters belong to the second group, and so on. The final group may contain fewer than k characters.
Replace each group with the string representation of the sum of its digits.
Concatenate all resulting strings in their original order to form the updated string s.
Repeat this process until the length of s is less than or equal to k.
Return s after completing all possible rounds.
Constraints:
s.length
k
s consists of digits only.