mediumFast & Slow Pointers Pattern

Happy Number

A happy number is defined by the following process: - Starting with any positive integer, replace the number by the sum of the squares of its digits. - Repeat until the number equals 1 (happy), or loops endlessly in a cycle. Return `true` if n is a happy number, `false` otherwise.

Examples

Input:n = 19
Output:true

Explanation: 1² + 9² = 82 → 8² + 2² = 68 → ... → 1

Hints (0/2)

Try to solve it first! Click "Reveal Next Hint" if you get stuck.

Your Code:
Results:
Output

Click "Run" to execute your code