Data Structures & AlgorithmsHardGATE CS · TCS NQT
What is the length of the longest prefix of abacaba that is a palindrome?
- A. 7
- B. 8
- C. 5
- D. 10
Correct answer: A. 7
The whole string abacaba is a palindrome, so the longest palindromic prefix is the whole string of length 7.
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 floor(i / 2) for i = 1 to 10?
- What is the smallest positive integer that has exactly 6 positive divisors?
- How many integers n in [1, 100] have both n and n + 2 prime?
- What is gcd(2^12 - 1, 2^8 - 1)?
- How many integers in [2, 20] are neither divisible by 2 nor by 3?
- How many division steps (modulo operations) does Euclid's algorithm perform on the pair (252, 105) before the remainder becomes 0?