File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed
0187-repeated-dna-sequences Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff 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 * 6 + charCode [ s [ i ] ] ;
19+ rollingHash = rollingHash * 4 + 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 * 6 + charCode [ s [ i ] ] ;
27+ rollingHash = rollingHash * 4 + 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 ( 6 , 9 ) ;
42+ rollingHash -= charCode [ s [ i - 9 ] ] * Math . pow ( 4 , 9 ) ;
4343 }
4444
4545 return result ;
You can’t perform that action at this time.
0 commit comments