Skip to content
playdsa
Preferences

Make yourself comfortable.

Saved on this browser. Your device’s reduced-motion preference is always respected.

Theme
Advanced settings

The Two Sentinels

Learn
Play
Prove
Lesson 1 of 5

Live algorithm trace

Palindrome sentinels

Complete execution
1 of 5

Place sentinels at both ends of `ab_a`.

1left = 0; right = length - 1
2skip non-alphanumeric characters
3if lowercase(left) != lowercase(right): return false
4left += 1; right -= 1
5return true
left = 0right = 3

Meet the two pointers, twin sentinels. One starts at the left edge, one at the right. They walk toward each other.

Help shape PlayDSA

Something confusing, broken, or missing? Leave a quick note without leaving your lesson.

Please leave out passwords, payment details and other private information.

Page included: /

Sign in to save feedback here, or send it with your email app. Your draft stays here while you sign in.

Open email instead