You are viewing a single comment's thread. Return to all comments →
Hey 7ovana,
I am try to do the code as below. But not pass all the test and shows that time exceed. Any idea why this approach is slower than yours, please?
def superDigit(n, k): if len(n) == 1: return n n = n * k while len(n) > 1: n = superDigit_helper(n) return n def superDigit_helper(n): return str(sum(map(int, n)))
Seems like cookies are disabled on this browser, please enable them to open this website
I agree to HackerRank's Terms of Service and Privacy Policy.
Recursive Digit Sum
You are viewing a single comment's thread. Return to all comments →
Hey 7ovana,
I am try to do the code as below. But not pass all the test and shows that time exceed. Any idea why this approach is slower than yours, please?