medium10 pts · first answer countshash-mapsetscycle-detection
Detecting a loop in repeated digit squares
Repeatedly replacing a number with the sum of squares of its digits either reaches 1 or loops forever. What does a Set of seen values let you detect, and is 19 happy?
Discussion 0
Join free to post in the discussion.
Related questions
- Courses that require each otherBackend Developer
- Kahn’s algorithm finishes earlyBackend Developer
- Average cost of a hash map lookupBackend Developer
- Worst case for a hash map lookupBackend Developer
- Removing duplicates with a SetBackend Developer
- Number keys in a plain objectBackend Developer
- Iteration order of a MapBackend Developer
- When to choose Map over a plain objectBackend Developer