Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS

What is the length of the longest palindromic substring of "forgeeksskeegfor"?

  1. A. 8
  2. B. 1
  3. C. 16
  4. D. 10

Correct answer: D. 10

Expanding around each centre finds the even-length palindrome 'geeksskeeg' centred between the two s letters: length 10. Trying only odd centres finds no palindrome longer than 1, stopping one step early gives 8, and 16 is the whole string.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic