Data Structures & AlgorithmsModerateTCS NQT · Infosys

Problem: Count the substrings of length 3 in "xyzzaz" that contain three distinct characters.

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

Correct answer: D. 1

Check each window of length 3 for distinct letters. Counting windows where the first and last letters differ is a looser condition.

More Coding Interview Problems questions

Exams that ask this topic