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?
- A. 1
- B. 10
- C. 2
- 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.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- What is the length of the longest substring of "eceeebbaccbbaaceddccc" that contains AT MOST two distinct letters?
- In the list ['listen', 'silent', 'enlist', 'google', 'gooegl', 'cat', 'act', 'tac', 'dog'], how many unordered pairs of different…
- How many index pairs (i < j) of the list [1, 3, 2, 3, 4, 5, 3, 1, 2, 5] satisfy a[i] + a[j] = 6? Equal values at different positions count…
- How many unordered pairs of distinct positions in [2, 3, 4, 6, 8, 9, 12] have a product divisible by 6?
- How many DISTINCT substrings of length exactly 3 does "abcabcbb" contain?
- How many substrings of "aeixoaeiuxoaeiou" consist only of vowels AND contain all five vowels a, e, i, o, u at least once?