Virtual Algorithm Lab

Palindrome Checker

{ }
++ ++
0
0
s[l] == s[r] — Convergence
Palindrome Two-Pointer System
drag to rotate · pinch to zoom · 2-finger drag to pan
L
R

Palindrome Checker

"racecar" → true · two markers converge inward checking symmetry

The Word, Live
Custom Word:
Step by Step
Step 1 / 9

The Code Behind It
palindrome.py

    
In plain English:
Theory & Fundamentals

The Two-Pointer Technique

A palindrome is a sequence that reads the same forwards and backwards. By using a Left and Right pointer, we check characters from the outside in. If any pair doesn't match, we can immediately exit (return False). This achieves O(1) auxiliary space and O(N) time complexity.

Knowledge Check

Q1: Tracing the Algorithm

If the word is "RADAR", what is the value of s[l] and s[r] on the very first step?

Q2: Early Exit

If we check the word "HELLO", how many pairs of letters do we actually compare before knowing it's not a palindrome?

Q3: Space Complexity

What is the auxiliary space complexity of checking a palindrome using two pointers?