Data Structures & AlgorithmsModerateTCS NQT · Accenture
Problem: A word is "statistics". How many distinct letters appear at least twice in it?
- A. 4
- B. 2
- C. 3
- D. 5
Correct answer: C. 3
Letters s (3), t (3), a (1), i (2), c (1) — the letters with at least two occurrences are s, t and i, so the answer is three.
More Coding Interview Problems questions
- Problem: A sorted array [2, 3, 5, 7, 11, 13, 17, 19] is searched for 11 using binary search with mid = (lo + hi) // 2 over the inclusive…
- Problem: Consider the string "xyzzyzyx". How many distinct substrings of length 2 are there?
- Problem: The array [1, 4, 6, 3, 8, 2] is processed by a single pass that tracks the maximum so far. How many elements are records…
- Problem: A set of 10 people is divided into 5 pairs. How many distinct ways are there to form these pairs (unordered pairs, unordered…
- Problem: In the array [5, 8, 3, 7, 2], find the second-largest element.
- Problem: A tree with 5 nodes is given by the parent array p = [−1, 0, 0, 1, 1] (node 0 is the root). How many leaves does it have?