awelgorithms

Happy Number: the skills you need first

Updated

LeetCode · easy · hash sets. The sum-of-squares walk is a chain. A seen-set catches the cycle.

open on LeetCode

Skills this problem builds on

Stuck on Happy Number? It is usually one of these. Get each one solid and the solution stops being a trick.

  1. Mark visited with a set
  2. Detect a repeat visit
check which ones you have 10 minutes, free, no account.

More hash sets problems