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

0% completed

Vote For New Content
Python3 solution's 3rd line should be `bit_count, n = 0, num`. It also fails for...

J

Dec 7, 2022

Python3 solution's 3rd line should be bit_count, n = 0, num. It also fails for test case num = 0 unless you include an if statement for that edge case i.e. adding the line if num == 0: return 1 before line 3.

3

0

Comments
Comments
Design Gurus
Design Gurus2 years ago

This problem expects only positive number as input, zero won't be a valid input.

On this page