Data Structures & AlgorithmsHardCodeforces Div2 B-D · ICPC regional

Concatenate "abba" and "baab" into one string, then count its distinct substrings of length 2.

  1. A. 4
  2. B. 5
  3. C. 3
  4. D. 7

Correct answer: A. 4

Collect all length-2 windows of the 8-character concatenation into a set, including the boundary window formed by the join. Forgetting the boundary window undercounts by one.

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

Exams that ask this topic