Data Structures & AlgorithmsHardGATE CS · ICPC regional

How many length-3 windows of the string aabxaaba have at most one position that differs from the pattern aab?

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

Correct answer: B. 2

Count mismatches for each window and keep those with one or zero differences. A window with two differing positions is excluded even if it is close.

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

Exams that ask this topic