02:04Competitive Programming Tutorial #73 | The Z-function and the Z-algorithm
From the creator
Competitive Programming Tutorial: Episode 73 of SyntaxPilot's free Competitive Programming full course, with real-life examples for every concept. The Z-function and the Z-algorithm. In this video you'll learn: • Original Problem S1: the echo score of a string • Why comparing from every position is too slow • The Z-box: reuse what you already matched • z[i] = min(r − i, z[i − l]) and why it is O(n) • A real overflow: int vs long long on a million letters • Original Problem S2: merge two fragments with the longest overlap • z of b + '#' + a, and the reaches-the-end check • 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_ep73/ Chapters 00:00 Welcome 00:26 Today's agenda 00:43 Echo score 01:22 Every position: TLE 02:09 A copied notebook 02:46 The Z-box 03:40 Why it is O(n) 04:23 The Z-box 04:35 A real overflow 05:39 Message merge 08:08 Complexity vs the constraints 08:38 Common mistakes 09:09 What you invented 09:37 Quick quiz 10:07 Recap and homework 10:45 Next episode Next episode: Manacher's algorithm Post your homework and quiz answer in the comments, and subscribe for the full basic-to-master playlist, free. #Competitive P
Published 2026-11-27 · Watch on YouTube ↗
Availability and playback restrictions are controlled by the original channel.
Keep exploring Learn to Code
02:04
05:29C Programming Tutorial for Beginners | Introduction to Programming & C Language
YK Studio
03:003 Core Components of Prisma ORM Explained 🔥 | Backend Development #coding #programming #nodejs
VIRTUAL CODE
01:43
10:09OpenCode Rune: All New Native Rust Desktop App for the OpenCode Coding Agent
AI Stack Engineer
01:46
02:02Два мільярди рядків коду — це одна програма? 🤯 #програмування #Google #coding
Школа програмування