Skip to content

Commit d329164

Browse files
authored
Update find-substring-with-given-hash-value.cpp
1 parent 8812168 commit d329164

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

C++/find-substring-with-given-hash-value.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class Solution {
77
string subStrHash(string s, int power, int modulo, int k, int hashValue) {
88
int idx = 0;
99
for (int64_t i = size(s) - 1, pw = 1, h = 0; i >= 0; --i) {
10-
if (i > size(s) - k) {
10+
if ((size(s) - 1) - i + 1 <= k - 1) {
1111
pw = (pw * power) % modulo;
1212
}
1313
if (i + k < size(s)) {

0 commit comments

Comments
 (0)