tubeshowcase●1,685,766 videos♡ My collection 0
← Learn to Code

Learn to Code10:31

Competitive Programming Tutorial #74 | Manacher: the longest palindrome in O(n)

SyntaxPilot ↗

From the creator

Competitive Programming Tutorial: Episode 74 of SyntaxPilot's free Competitive Programming full course, with real-life examples for every concept. Manacher: the longest palindrome in O(n). In this video you'll learn: • Original Problem M1: the longest palindromic stretch • Expand around every centre, and why it is too slow • The mirror trick inside the rightmost palindrome • d[i] = min(d[l + r − i], r − i + 1) and why it is O(n) • The even-length bug, and the '#' transform • Original Problem M2: count palindromic substrings • Stress tests and complexity against the constraints Every concept starts with a real-life example, then an animation and notes, then live code in the SyntaxPilot online compiler. Practice free in the SyntaxPilot compiler (nothing to install): https://syntaxpilot-learning-2026.web.app/ Detailed notes for this episode (code, outputs, practice): https://syntaxpilot-learning-2026.web.app/notes/cp/cp_ep74/ Chapters 00:00 Welcome 00:26 Today's agenda 00:42 Mirror street 01:24 Every centre: TLE 02:09 A symmetric rangoli 02:46 The mirror 03:38 Why it is O(n) 04:12 The mirror 04:26 The even bug and # 05:44 Palindrome count 07:43 Complexity vs the constraints 08:12 Common mistakes 08:44 What you invented 09:07 Quick quiz 09:37 Recap and homework 10:12 Next episode Next episode: Trie and XOR-maximisation problems Post your homework and quiz answer in the comments, and subscribe for the full basic-to-master playlist, free. #Competitive Programming #Competitiv

Published 2026-11-29 · Watch on YouTube ↗
Availability and playback restrictions are controlled by the original channel.

Keep exploring Learn to Code