6 line Solution using python3 yt


#1
class Solution:
    def power(self, A):
        if(A=="1"):
            return 0
        b=bin(int(A)).replace("0b","")
        if(b.count('1')==1 and b[0]=='1'):
            return 1
        return 0

suggestions are welcomed.Preformatted text


#2

Hey, can i know why did u do b[0]==‘1’ ? Whats the use of this condition?


#3

No use of this condition. Even I don’t remember why I wrote like that. Maybe the thought process was different that time.


#4

Intention of question is to solve by storing the numbers in array, not by using builtin libraries.