GATE Computer ScienceHardGATE CS (PYQ pattern)
What is the length of the longest palindromic substring (contiguous) of xabcbaxyzzyxabcdcbay?
- A. 12
- B. 6
- C. 8
- D. 10
Correct answer: A. 12
The substring cbaxyzzyxabc (positions 3 to 14) reads the same forwards and backwards. Expanding around the even centre between the two z characters keeps matching for 6 steps on each side: length 12. The odd palindromes abcba and abcdcba are shorter.
More Algorithms questions
- Consider the congruence 46x ≡ 18 (mod 240). How many solutions x does it have in 0…239, and what is the smallest one?
- How many integers in 1…1000 are coprime to 360?
- A dynamic array has capacity 1 initially. An append to a full array doubles the capacity (copying all n current elements); after a…
- A 4-input comparator network applies, in order, the comparators (0,1), (2,3), (0,2), (1,3), (1,2), each putting the smaller value on the…
- How many comparators does Batcher's bitonic sorting network for 16 inputs use?
- Which is the tight solution of T(n) = 3T(n/4) + n^(log₄3)·log₂ n?