A happy number is defined by the following process:
Numbers for which this process ends at 1 are happy. Return true if n is a happy number, and false otherwise.
Input: n = 19 Output: true Explanation: 1^2 + 9^2 = 82 -> 8^2 + 2^2 = 68 -> 6^2 + 8^2 = 100 -> 1^2 + 0^2 + 0^2 = 1
Input: n = 2 Output: false Explanation: 2 -> 4 -> 16 -> 37 -> 58 -> 89 -> 145 -> 42 -> 20 -> 4 (cycle detected, never reaches 1)
1 <= n <= 2^31 - 1n = 19