Count the distinct numbers reached by halving or decrementing num.
Unlock detailed company stats for this questionUpgrade
Given num <= 10^9 and s <= 60, there are two operations: if num is even, replace it with num / 2; if num > 0, replace it with num - 1. Perform the operations and count the distinct numbers encountered. A BFS with a visited set works because the number of reachable states is small.
Community answers
No answers contributed by the community yet.
Related questions
Count the number of distinct islands in a grid.Related courses

Course

Course
Course
