Data Structures & AlgorithmsHardTCS NQT · Infosys

How many distinct strings can be obtained from abc by swapping two adjacent characters at most once (including the original string)?

  1. A. 4
  2. B. 3
  3. C. {C-1}
  4. D. 5

Correct answer: B. 3

The original abc plus the strings bac and acb from the two adjacent swaps make 3 distinct results.

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

Exams that ask this topic