Using a unordered_set STL to improve the speed of detecting loop.

```
class Solution {
public:
bool isHappy(int n) {
unordered_set<int> s;
while (n != 1 && s.find(n) == s.end()) {
s.insert(n);
int tmp = 0;
while (n != 0) {
tmp += ((n%10)*(n%10));
n /= 10;
}
n = tmp;
}
if (n == 1) return true;
else return false;
}
};
```