#1945
Sum of Digits of String After Convert
newbie · 235 · lc easy +18 · 74.8% accepted · 1,199 likes · top 85%
Description
Given a string s of lowercase English letters and an integer k:
- Replace each letter with its 1-based alphabetical position and concatenate all the results into a new string.
- Repeat k times: replace the current number string with the sum of its digits.
Return the final single-digit (or multi-digit) integer after all transformations.
Code
1
2
3