‹ DS&A interview · Socratic
DSA · Two pointers (string) · #25

Valid Palindrome

Module 28 · difficulty 1/5·30:00starts on first keystroke

A phrase is a palindrome if, after lowercasing and removing all non-alphanumeric characters, it reads the same forwards and backwards. Given a string `s`, return `true` if it is a palindrome, `false` otherwise.

Examples
  • s = "A man, a plan, a canal: Panama" true
  • s = "race a car" false
  • s = " " trueempty after cleaning

Stuck? Reveal an animated walkthrough of the approach.

Constraints
  • · 1 <= s.length <= 2·10^5
  • · s consists of printable ASCII characters.
Session phases
A · Clarify
B · Approach
C · Complexity
D · Edges
E · Code
F · Tradeoff
G · Score
Phase A — Clarify
Ask questions about input bounds, types, and edge constraints.
Ask the coach clarifying questions about the problem.
When you've covered this phase, advance to the next.