Data Structures & AlgorithmsHardTCS NQT · Product Company SDE

Problem: In the string "aabcbcdbca", what is the length of the shortest substring that contains exactly 3 distinct letters?

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

Correct answer: B. 3

Among substrings with exactly three distinct letters, the shortest is found by checking all index ranges. Finding the longest substring with three letters is a different question.

More Coding Interview Problems questions

Exams that ask this topic