Data Structures & AlgorithmsHardICPC regional · strings
Problem: Which claim about the Manacher algorithm is correct?
- A. It needs O(n^2) time because it compares all pairs
- B. It only works on binary strings
- C. It finds all palindromic substring radii in O(n) time
- D. It returns the number of inversions
Correct answer: C. It finds all palindromic substring radii in O(n) time
The mirror property of palindromes lets Manacher reuse radii, giving linear time overall.
More Coding Interview Problems questions
- Problem: Which concept is used by the Rabin-Karp algorithm to compare substrings in constant time?
- Problem: What is the number of comparisons needed by heapsort in the worst case for n elements?
- Problem: Which algorithm finds the k-th smallest element in expected linear time?
- Problem: Which property does the KMP failure function of a string satisfy?
- Problem: Which is the time complexity of deciding whether an undirected graph has an Euler path?
- Problem: How many pairs (i, j) with 1 <= i < j <= 20 satisfy i j ≡ 1 (mod 7)? Run the code. python print(sum(1 for i in range(1, 21) for j…