Home
Log in
DescriptionSubmissionsSolution
DescriptionSubmissionsSolution
Loading...

Log in to run or submit

n =

Codey

Practise coding problems, test your solutions and track your progress.

Explore

  • Problems
  • About
  • Contact

Legal

  • Privacy Policy
  • Terms of Use

© 2026 Codey. Personal learning project.

Solution
Updated: 2026-02-23

Idea

Repeated sum-of-squares-of-digits forms a sequence; happy numbers reach 1, others cycle.

Approach

Use Floyd cycle detection on the transformation next(n). Return true iff the fast pointer reaches 1.

Code
Loading...
Complexity
Time: O(k)
Space: O(1)
Solution
Updated: 2026-02-23

Idea

Repeated sum-of-squares-of-digits forms a sequence; happy numbers reach 1, others cycle.

Approach

Use Floyd cycle detection on the transformation next(n). Return true iff the fast pointer reaches 1.

Code
Loading...
Complexity
Time: O(k)
Space: O(1)