Data Structures & AlgorithmsModerateCodeforces Div2 B-D · ICPC regional

For "abcdab", list the five length-2 substrings and hash each as (ord(first) + ord(second)) mod 11. How many index pairs i < j have equal hash values?

  1. A. 2
  2. B. 3
  3. C. 4
  4. D. 8

Correct answer: A. 2

Compute the five hashes and count equal pairs. Equal substrings always share a hash, but the count also includes unequal substrings that collide.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic