InferenceAI

Enter at least two characters to search.

Start free

Alphanumeric Palindrome

easyTwo Pointers15 min10 XP

Return True if text reads the same forwards and backwards after removing every character that is not a letter or digit and ignoring case.

Requirements

  • Use two pointers and O(1)O(1) extra space.

Examples

EXAMPLE WALKTHROUGHclassic sentence

A guided view of the published example, not a trace of your code.

INPUT["A man, a plan, a canal: Panama"]
TASKalphanumeric_palindrome()
EXPECTED OUTPUTtrue

Start with the input values shown in this example.

Example 1 of 3

Input: text = "A man, a plan, a canal: Panama"

Output: true

Explanation: classic sentence

Input: text = "race a car"

Output: false

Explanation: not a palindrome

Input: text = " "

Output: true

Explanation: only spaces

Hint 1

Move a left pointer and a right pointer towards each other, skipping non-alphanumeric characters.

Topics

DSATwo PointersPython