public static boolean isHappy(int n) {
    Map<Integer, Boolean> traverseMap = new HashMap<Integer, Boolean>();
    int res = n;
    while (true) {
      res = assistIsHappy(res);
      if (1 == res) return true;
      if (traverseMap.containsKey(res)) return false;
      traverseMap.put(res, true);
    }
  }