Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS

What is the largest number of distinct characters in any contiguous window of length 4 of "abcbdabca"?

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

Correct answer: D. 4

Scan all windows of length 4 and count distinct letters; a window with four different letters exists here. A count of 3 (the last-but-one option) describes the windows with a repeat.

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

Exams that ask this topic