2 minutes
Leetcode 1945
1945. Sum of Digits of String After Convert
The Mathematical Solution:
The idea of this solution uses the fact that k
will always be 1 <= k <= 10
. Since k
will always be greater than 1
we can add the first transformation and conversion together, so we don’t add numbers that are greater than 9
to the result.
For an example let us use:
input: s = "hvmhoasabayzzzzzd", k = 1
The Boring String Solution:
Read other posts