Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
The time complexity of
n - 1
andn & m
is notO(1)
in Python. Moreover, builtin functions are much faster in Python. That's why the solution from the link is significantly faster than yours on relatively large inputs.Try to run your solution with
n = (1 << 500000) - 1
and this solution with the samen
.For relatively small numbers there's no difference. If you test it with huge inputs like
(1 << 65536) - 1
, it's super slow compared to others.that's right for Python 3 (this solution passes the kata in Python 2)