Data Structures & AlgorithmsVery hardGATE CS · ICPC regional
What is the length of the longest palindromic substring of xabacdcabay?
- A. 8
- B. 11
- C. 13
- D. 9
Correct answer: D. 9
The longest palindrome is abacdcaba, centred on the d. Expanding around each of the 2n-1 centres finds the maximum in O(n^2) time, and Manacher's algorithm does it in O(n).
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 minimum number of cuts needed to partition the string abacdcdad into palindromic pieces?
- How many times does the pattern aba occur in ababababa when occurrences may overlap?
- For the string aabaaabaa, what is the sum of the Z-function values Z[1] + Z[2] + ... + Z[n-1] (Z[i] is the longest common prefix of the…
- How many distinct substrings of length 3 does the string abcabcabd have?
- How many substrings of abcabcbb contain no repeated character?
- Evaluate the postfix (reverse Polish) expression 5 1 2 + 4 + 3 -. What is the value?