Data Structures & AlgorithmsModerateTCS NQT · Infosys

In "swissmississippi", what is the 0-based index of the first character that appears exactly once in the whole string?

  1. A. 1
  2. B. 10
  3. C. 2
  4. D. 0

Correct answer: A. 1

Count frequencies in one pass, then scan again for the first count of 1. Stopping at the first character that does not repeat right away (a single-pass check) can return the wrong index.

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

Exams that ask this topic