Data Structures & AlgorithmsVery hardTCS NQT · Accenture
How many contiguous non-empty substrings of aaabbbaa consist of a single repeated letter?
- A. 15
- B. 16
- C. 17
- D. 19
Correct answer: A. 15
Runs of length 3, 3 and 2 contribute 6, 6 and 3 substrings, so the total is 15.
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 sum of the distinct prime divisors of 2310?
- How many positive divisors does 2^5 3^3 5^2 have?
- How many integers x in [1, 200] are divisible by 4 but not by 6?
- What is the sum of (x^2 mod 13) for x = 1 to 12, taken modulo 13?
- How many ordered pairs (a, b) with 1 <= a, b <= 10 satisfy (a + b) mod 5 = 0?
- What is the modular inverse of 3 modulo 11, that is the x in [0, 10] with 3x ≡ 1 (mod 11)?