Happy Number
A easy-tier problem at 58% community acceptance, tagged with Hash Table, Math, Two Pointers. Reported in interviews at BlackRock and 21 others.
Happy Number is an easy problem that hits your screen more often than you'd expect. BlackRock, Jump Trading, Nike, Verily, and Airbnb all ask it. The acceptance rate sits around 58 percent, which sounds forgiving until you realize candidates blank on the core trick during a live assessment. The problem feels simple on read, which is exactly why people overthink it or get stuck in infinite loops. If this one lands in your OA and you freeze, StealthCoder surfaces a working solution invisible to the proctor.
Companies that ask "Happy Number"
Happy Number is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Made by a working Amazon engineer who got tired of watching qualified friends bomb OAs they'd solve cold in an IDE.
Get StealthCoderThe trick is recognizing that you're chasing a cycle. You repeatedly sum the squares of digits until you hit 1 (happy) or loop forever (not happy). Most candidates start coding without realizing a cycle detector is mandatory. You'll see attempts at naive recursion, arbitrary depth limits, or unbounded loops that time out. The pattern lives in Hash Table or Two Pointers (Floyd's cycle detection). Hash Table is the straightforward route: store seen sums and bail when you revisit one. Two Pointers is the clever approach: slow and fast runners on the sum sequence catch cycles without extra space. During a live OA, picking the wrong mental model wastes minutes. StealthCoder handles both, so you don't burn time deciding.
Pattern tags
You know the problem.
Make sure you actually pass it.
Happy Number recycles across companies for a reason. It's easy-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Made by a working Amazon engineer who got tired of watching qualified friends bomb OAs they'd solve cold in an IDE. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Happy Number interview FAQ
Why does the naive recursion approach fail?+
Without cycle detection, you'll recurse forever on non-happy numbers. You need either a visited set (Hash Table) or Floyd's algorithm (Two Pointers) to break the loop. The problem guarantees all sequences cycle; you just need to catch it.
Is Happy Number still asked by big companies?+
Yes. Ten major companies in the input data ask it: BlackRock, Jump Trading, Nike, Verily, Accenture, Snowflake, X, Swiggy, Airbnb, and FactSet. It's a staple that doesn't rotate out.
What's the difference between Hash Table and Two Pointers here?+
Hash Table is intuitive: store each sum you've seen and stop when you revisit one. Two Pointers (Floyd's cycle detection) uses O(1) space by running a slow and fast cursor on the sum sequence. Both work; Hash Table is easier to explain under pressure.
How long does the cycle actually get?+
The cycle length varies, but it's usually short (often less than 10 steps before repeating or hitting 1). You don't need to predict it. Just detect it with a set or runners and the algorithm terminates fast.
Is this really an easy problem?+
The acceptance rate is 58 percent, which for easy is lower than typical. The simplicity is a trap. Candidates know what happy numbers are but forget to handle cycles. That's where interviews are won and lost.
Want the actual problem statement? View "Happy Number" on LeetCode →