zoukankan      html  css  js  c++  java
  • leetcode-每日打卡-day 7

    leetcode 每日打卡

    those times when you get up early and you work hard; those times when you stay up late and you work hard; those times when don’t feel like working — you’re too tired, you don’t want to push yourself — but you do it anyway. That is actually the dream. That’s the dream. It’s not the destination, it’s the journey. And if you guys can understand that, what you’ll see happen is that you won’t accomplish your dreams, your dreams won’t come true, something greater will. mamba out


    那些你早出晚归付出的刻苦努力,你不想训练,当你觉的太累了但还是要咬牙坚持的时候,那就是在追逐梦想,不要在意终点有什么,要享受路途的过程,或许你不能成就梦想,但一定会有更伟大的事情随之而来。 mamba out~

    2020.2.15


    记录下来自己做题时得思路,并不一定是最优解

    136. 只出现一次的数字

    class Solution:
        def singleNumber(self, nums: List[int]) -> int:
            x = 0
            for i in nums:
                x ^= i
            return x
    

    191. 位1的个数

    class Solution:
        def hammingWeight(self, n: int) -> int:
            ans = 0
            while n > 0:
                ans += n & 1
                n = n >> 1
            return ans
    

    231. 2的幂

    class Solution:
        def isPowerOfTwo(self, n: int) -> bool:
            return (n > 0) and (n & -n) == n
    
  • 相关阅读:
    《C》指针
    《C》变量
    《C》数组
    《C》VS控制台应用
    listagg wm_concat 行转列
    Linux学习之shell script
    Linux学习之正则表达式sed
    Linux学习之正则表达式grep
    Linux学习之SAMBA共享(密码验证)
    Linux学习之SAMBA共享(无密码)
  • 原文地址:https://www.cnblogs.com/wlw-x/p/12315041.html
Copyright © 2011-2022 走看看