Write an algorithm to determine if a number n is happy.
A happy number is a number defined by the following process:
Return true if n is a happy number, and false otherwise.
This problem demonstrates that the fast & slow pointer technique applies beyond linked lists! The sequence of digit-square-sums forms an implicit linked list. If the number is not happy, the sequence will cycle, which we can detect using Floyd's algorithm.
n = 19truen = 2false1 <= n <= 2^31 - 1Click "Run" to execute your code against test cases
Socratic guidance - I'll ask questions, not give answers