Embercode
✕
Character Arrays and StringsQuick quiz

Rolling hash

6 questions. Covers Rolling hash.

Questions 1 to 5 of 6

  1. 1. After a PrefixHash is built for a string of n letters, how many steps does one call to get(start, len) take, whatever len is? Do not count a character check.
  2. 2. How many steps does it take to build the prefix and power arrays for a string of n letters?
  3. 3. Why does findAll compare the characters with text.compare after the two numbers match?
  4. 4. In get, the code is upper + mod_ - removed, with mod_ added before the subtraction. Why?
  5. 5. What does this program print? ``cpp #include <cstdint> #include <iostream> int main() { const uint64_t mod = 11; uint64_t upper = 1068 % mod; uint64_t removed = 97 % mod * 10 % mod; std::cout << (upper + mod - removed) % mod << "\n"; } ``

5 question(s) left on this page.