awelgorithms

Valid Palindrome: the skills you need first

Updated

LeetCode · easy · two pointers. Skip junk, lowercase, then close the gap. Mismatch is the answer.

open on LeetCode

Skills this problem builds on

Stuck on Valid Palindrome? It is usually one of these. Get each one solid and the solution stops being a trick.

  1. Place opposite-end pointers

    Opposite-end placement puts L at index 0 and R at index n-1 so the two indices face each other across the whole array. You name them from length. You do not scan to find the ends.

  2. Skip non-alphanumeric characters
  3. Convert a character to lowercase
check which ones you have 10 minutes, free, no account.

More two pointers problems