Data Structures & AlgorithmsHardGoogle · Strings

What is the length of the shortest substring of "AXBYAZCBAB" that contains at least two A's, at least one B and at least one C?

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

Correct answer: B. 5

The window "AZCBA" (the 5th to 9th characters) holds two A's, a B and a C; no 4-letter window can.

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

Exams that ask this topic