LeetCode: Sum of Digits of String After Convert Solution
Solving a problem in one go is such a good feelingImplementation
1var getLucky = function (s, k) {2 let transform = s3 .split("")4 .map(char => char.charCodeAt(0) - "a".charCodeAt(0) + 1)5 .join("")67 while (k--) {8 transform = transform9 .split("")10 .map(Number)11 .reduce((acc, el) => acc + el, 0)12 .toString()13 }1415 return transform16}
References
Similar problems
Comments
Loading comments...
Tags
leetcode
string
math
Apply and earn a $2,500 bonus once you're hired on your first job!
Clients from the Fortune 500 to Silicon Valley startups
Choose your own rate, get paid on time
From hourly, part-time, to full-time positions
Flexible remote working environment
A lot of open JavaScript jobs!!
Fact corner: Referred talent are 5x more likely to pass the Toptal screening process than the average applicant.
Still hesitate? Read HoningJS author's guide on dealing with Toptal interview process.