← All problemsSign in

All Palindromes

CSESString AlgorithmsOpen on judge ↗

Given a string, calculate for each position the length of the longest palindrome that ends at that position. Input The only line contains a string of length n. Each character is one of a–z. Output Print n numbers: the length of each palindrome. Constraints - 1 \le n \le 2 \cdot 10^5 Example Input: ababbababaa Output: 1 1 3 3 2 4 6 8 5 5 2

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start