Share python one line code


  • 0
    C
    def hammingWeight(self, n):
         return bin(n).count("1")
            #return [int(x) for x in bin(n)[2:]].count(1)

  • 0

    实在是太简单了!!!!!!!!!!了不起!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.