由买买提看人间百态

topics

全部话题 - 话题: 0x3fffffff
(共0页)
a***e
发帖数: 413
1
来自主题: JobHunting版 - 问一下Repeated DNA Sequences
自己做的总是memory exceeded,
看了讨论,
https://oj.leetcode.com/discuss/24478/i-did-it-in-10-lines-of-c
还是不懂为啥m[t = t << 3 & 0x3FFFFFFF | s[i] & 7]++ == 1就能达到rolling hash
的效果呢?
i只是一个char啊,这个是哪里推导出来的?多谢!
Neat idea. The additional 1 bit per letter still encode each substring in
10x3 = 30 bits, just under 4 bytes for a 32-bit integer.
Your code could be further simplified. By observing that s[i] & 7 is never 0
, each of the first nine substrings with length < 10 will have unique hash
key and will never collid... 阅读全帖
p*******e
发帖数: 4
2
来自主题: JobHunting版 - 问一下Repeated DNA Sequences
你不一定非要用这种方法,一个字母用2个bit表示,就不会memory exceed了
m[t = t << 3 & 0x3FFFFFFF | s[i] & 7]++ == 1
这里的s[i] & 7 是取下一个字母N,
t << 3 & 0x3FFFFFFF 是保留当前10-letter string的后9个letter S,
| 是把 N 合并到S中,这样就更新了key
(共0页)