Data Structures & AlgorithmsHardGATE CS · TCS NQT

In "abcdbefg", what is the 0-based index of the first character that repeats an earlier character?

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

Correct answer: B. 4

Scan with a set and report the first index whose character is already present. The repeated 'b' appears at index 4.

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

Exams that ask this topic