I don't know why it is still very slow compare to other solution. Any other good method??? so confuseddd
if(n<=0) return false;
Your method runs in O(lgn) time, where n is the number of bits used to represent the number. Try using bit-wise operation then you can reduce the time complexity down to O(1), which is faster.
Yep, you are right, thanks a lot. Dude
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.