LeetCode 202 - Happy Number(cycle detection)
Read question here: https://leetcode.com/problems/happy-number/
Solution:
class Solution {
public boolean isHappy(int n) {
int slow = squaredSum(n);
int fast = squaredSum(squaredSum(n));
while (slow != fast) {
slow = squaredSum(s...
imkraman.hashnode.dev5 min read