![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
异或运算
BlackMan_阿伟
不积跬步无以至千里
展开
-
LeetCode——231.2的幂
class Solution: def isPowerOfTwo(self, n: int) -> bool: # num = 0 # for i in range(100): # num = 2**i # if num==n: # return True # if num>n: # return False ...原创 2021-01-31 09:29:43 · 93 阅读 · 0 评论 -
剑指 Offer 65. 不用加减乘除做加法
写一个函数,求两个整数之和,要求在函数体内不得使用 “+”、“-”、“*”、“/” 四则运算符号。示例:输入: a = 1, b = 1输出: 2不让用四则运算,那肯定就是与或运算,但是还是没看明白,直接背下来算了。class Solution: def add(self, a: int, b: int) -> int: while a!=0: temp = a^b a = (a & b)<&l原创 2020-07-16 15:48:13 · 71 阅读 · 0 评论