Data Structures & AlgorithmsModerateTCS NQT · Infosys

Problem: How many distinct two-letter substrings does "mississippi" contain?

  1. A. 10
  2. B. 4
  3. C. 16
  4. D. 7

Correct answer: D. 7

Slide a window of 2 and keep a set: mi, is, ss, si, ip, pp, pi → 7. Counting all 10 window positions double-counts is, ss, si, 4 is the number of distinct letters, and 16 counts every possible ordered pair of those letters.

More Coding Interview Problems questions

Exams that ask this topic