Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit fbffcce

Browse files
add a comment for 2156
1 parent c6404c5 commit fbffcce

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

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

+3-1
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
public String subStrHash(String s, int power, int modulo, int k, int hashValue) {
1113
long weight = 1;
@@ -43,6 +45,6 @@ public String subStrHash(String s, int power, int modulo, int k, int hashValue)
4345

4446
return result;
4547
}
46-
4748
}
49+
4850
}

0 commit comments

Comments
 (0)