Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfbffcce

Browse files
add a comment for 2156
1 parentc6404c5 commitfbffcce

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

‎src/main/java/com/fishercoder/solutions/_2156.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ public static class Solution1 {
66
* Credit: https://leetcode.com/problems/find-substring-with-given-hash-value/discuss/1730100/Java-rolling-hash(back-to-front)/1242659
77
* <p>
88
* We start from the right side and compute rolling hash when moving the window of size k towards the left.
9+
* This post explains why we need to start from the right and move towards the left: https://leetcode.com/problems/find-substring-with-given-hash-value/discuss/1730114/C%2B%2B-Rolling-Hash-O(N)-Time
10+
* so that we could use Rabin-Karp algorithm.
911
*/
1012
publicStringsubStrHash(Strings,intpower,intmodulo,intk,inthashValue) {
1113
longweight =1;
@@ -43,6 +45,6 @@ public String subStrHash(String s, int power, int modulo, int k, int hashValue)
4345

4446
returnresult;
4547
}
46-
4748
}
49+
4850
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp