Data Structures & AlgorithmsModerateGATE CS · CAT · MBA placement

Strings "ab" and "cde" are interleaved, keeping the internal order of each string. How many distinct strings can be formed this way?

  1. A. 5
  2. B. 12
  3. C. 20
  4. D. 10

Correct answer: D. 10

Choosing which 2 of the 5 output positions hold the letters of "ab" gives C(5,2) = 10 interleavings, because the order inside each string is fixed. Counting permutations of all five letters ignores the fixed order, and counting over 4 positions is a slip.

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

Exams that ask this topic