
本期知识点导图

1. 上期参考代码
class Solution {
public:
int bitsum(int n) {
int sum = 0;
while (n) {
int t = n % 10;
sum += t * t;
n /= 10;
}
return sum;
}
bool isHappy(int n) {
int slow = n, fast = bitsum(n);
while (slow != fast) {
slow = bitsum(slow);
fast = bitsum(bitsum(fast));
}
return fast == 1;
}
};
上期的重点是理解双指针的特殊用法,将值本身作为双指针。逻辑上不是很难,主要是概念有点抽象。
2. 本期题目解析










