Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS

How many substrings of "abcabc" are anagrams of "abc" (that is, have the same letters with the same counts)?

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

Correct answer: D. 4

Sliding window of length 3 with a count vector: each window whose multiset of letters equals a, b, c qualifies. Two windows qualify in this string.

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

Exams that ask this topic