Data Structures & AlgorithmsHardTCS NQT · Infosys
How many adjacent position pairs in the string abbaabab are equal to ab or ba (overlapping adjacent pairs counted)?
- A. 6
- B. 5
- C. 7
- D. 9
Correct answer: B. 5
Check each of the seven adjacent pairs: ab, bb, ba, aa, ab, ba, ab. Five of them are ab or ba.
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 lexicographically smallest rotation of the string bca?
- What is the sum of all integers x in [1, 50] that are divisible by 4 or by 6?
- How many positive divisors of 360 are odd?
- What is the largest n such that 1 + 2 + ... + n does not exceed 1000?
- How many primes p with 2 <= p <= 30 satisfy p ≡ 1 (mod 4)?
- How many integers x in [1, 100] satisfy x ≡ 3 (mod 4) and x ≡ 7 (mod 10)?