Data Structures & AlgorithmsModerateTCS NQT Digital · Infosys

Problem: For the string "abcabcdab", how many substrings of length 3 occur exactly once?

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

Correct answer: A. 5

Count the frequency of each length-3 substring and tally those with frequency one. Only 'abc' repeats (at positions 0 and 3), so the other five substrings occur exactly once.

More Coding Interview Problems questions

Exams that ask this topic