Data Structures & AlgorithmsVery hardICPC regional · Amazon SDE OA

How many distinct non-empty substrings does the string "abacaba" have?

  1. A. 22
  2. B. 28
  3. C. 21
  4. D. 19

Correct answer: C. 21

Count distinct strings, not positions. Equal substrings at different positions are counted once, so the answer is well below the 28 positional substrings.

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

Exams that ask this topic