Skip to content

Commit ddfb11b

Browse files
committed
Time: 64 ms (96.18%), Space: 50.2 MB (95.97%) - LeetHub
1 parent 01d16ce commit ddfb11b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

0187-repeated-dna-sequences/0187-repeated-dna-sequences.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ function findRepeatedDnaSequences(s) {
1616

1717
// calculate the rolling hash for the first 9 characters
1818
for (let i = 0; i < 9; i++) {
19-
rollingHash = rollingHash * 5 + charCode[s[i]];
19+
rollingHash = rollingHash * 6 + charCode[s[i]];
2020
}
2121

2222
const result = [];
2323

2424
for (let i = 9; i < s.length; i++) {
2525
// rolling hash for the 10 character window
2626
// s[i - 9 : i]
27-
rollingHash = rollingHash * 5 + charCode[s[i]];
27+
rollingHash = rollingHash * 6 + charCode[s[i]];
2828

2929
if (!hashMap.has(rollingHash)) {
3030
// if seeing hash the first time
@@ -39,7 +39,7 @@ function findRepeatedDnaSequences(s) {
3939

4040
// rolling hash for the 9 character window
4141
// s[i - 8 : i]
42-
rollingHash -= charCode[s[i - 9]] * Math.pow(5, 9);
42+
rollingHash -= charCode[s[i - 9]] * Math.pow(6, 9);
4343
}
4444

4545
return result;

0 commit comments

Comments
 (0)