Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Vote For New Content
Cady Shelhon
Why is -1 not a happy number?

Cady Shelhon

Aug 28, 2023

When you do -1^2, that will equal 1 and therefore should return true. Should there be a constraint in the question stating that only positive numbers are happy?

1

0

Comments
Comments
Christian Willsea
Christian Willsea2 years ago

I agree with this. I don't understand why -1 is not a happy number.

Design Gurus
Design Gurus2 years ago

Sorry for not clearly mentioning that the given number will be a positive number. We've updated the problem statement.

On this page