We’re preparing your current view and syncing the latest data.
Given a string s, and integers power, modulo, k, and hashValue, find the starting index of a substring of length k such that the hash value of the substring matches hashValue. The hash function is defined as: hash(s) = (val(s[0]) * power^0 + val(s[1]) * power^1 + ... + val(s[k-1]) * power^{k-1}) mod modulo, where val(c) is the positional value of character c (a=1, b=2, ..., z=26). Return the substring of length k from s that has the matching hash value. If multiple substrings are possible, return the first one.
A string s; integers power, modulo, k, and hashValue.
Return the substring of length k from s whose hash value equals hashValue.
1 <= k <= s.length <= 10^5; 1 <= power, modulo <= 10^9; 0 <= hashValue < modulo; s consists of lowercase English letters only.