Data Structures & AlgorithmsHardGATE CS · ICPC regional

Which algorithm finds the longest palindromic substring of a string in linear time?

  1. A. Dijkstra's algorithm
  2. B. Kruskal's algorithm
  3. C. Manacher's algorithm
  4. D. Bellman-Ford algorithm

Correct answer: C. Manacher's algorithm

Manacher's algorithm reuses palindrome radii from a mirrored centre to achieve O(n). The other three are graph algorithms, unrelated to strings.

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

Exams that ask this topic