文件名称:leetcode算法题主函数如何写-leetcode:leetcode
文件大小:80KB
文件格式:ZIP
更新时间:2024-07-19 22:59:49
系统开源
leetcode算法题主函数如何写 leetcode 个人leetcode刷题笔记 位运算 num<<1 xss=removed> num*2 num>>1 ==> num/2 num&1==1 ==> num为奇数 num&1==0 ==> num为偶数 num&-2 ==> 奇数减1, 即将末位1变为0, 和0xfffffffe(-2)取&即可; 997 & -2 = 996 n>0且n&(n-1)==0 ==>n=2^x ,满足n为2的幂 位置0(&0),位不变(&1) 0x80000000 = Integer.MIN_VALUE = -2^31 0x7fffffff = Integer.MAX_VALUE = 2^31-1 0xaaaaaaaa = 10101010101010101010101010101010 (偶数位为1,奇数位为0) 0x55555555 = 01010101010101010101010101010101 (偶数位为0,奇数位为1) 0x33333333 = 00110011001100110011001100110011 (1和0每隔两位交替出现) 0xccccc