LeetCode判断字符串是否循环-LeetCode:记录LeetCode刷题

时间:2021-07-01 05:48:14
【文件属性】:
文件名称:LeetCode判断字符串是否循环-LeetCode:记录LeetCode刷题
文件大小:3KB
文件格式:ZIP
更新时间:2021-07-01 05:48:14
系统开源 LeetCode判断字符串是否循环 LeetCode第一轮刷题记录 Hamming Distance 先将两个数异或,然后循环判断每一个bit是否为1 func hammingDistance(x int, y int) int { res:= 0 exc:= x ^ y for i:= 0; i < 32;i++ { j:=uint(i) res += (exc >> j) & 1 } return res } Number Complement 转化成2进制字符串,每一个字符的整数都跟1异或,在转化为int func findComplement(num int) int { numBinary := strconv.FormatInt(int64(num), 2) var conv []string numSlice := numBinary[0:] for _, value := range numSlice { temp := (value - 48) ^ 1 tempStr := strconv.Itoa(int(temp)) conv
【文件预览】:
LeetCode-master
----hamming_distance()
--------main.go(302B)
----keyboard_row()
--------main.go(1KB)
----README.md(2KB)
----find_complement()
--------main.go(540B)

网友评论