Compare Normalized ASCII Phrase Symmetry

Quick Overview

Check a printable-ASCII phrase for palindrome symmetry while ignoring punctuation and letter case but retaining digits.

Compare Normalized ASCII Phrase Symmetry

Company: Google

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: easy

Interview Round: Other

### Problem Check whether a string reads the same backward after removing every non-alphanumeric character and treating uppercase letters as lowercase. Alphanumeric means English letters and decimal digits. If filtering leaves no characters, the result is a palindrome. ```cpp bool isPalindrome(string s); ``` ### Examples ```text Input: s = "No 'x' in Nixon!" Output: true ``` Its normalized form is `noxinnixon`. ```text Input: s = "0P" Output: false ``` Digits are retained; `0p` is not symmetric. ### Constraints - The length is between 1 and 200000. - Every character is printable ASCII.

Overview: Check a printable-ASCII phrase for palindrome symmetry while ignoring punctuation and letter case but retaining digits.

Google logo
Google
Date not reported
easySoftware EngineerOtherCoding & Algorithms
0
0

Problem

Check whether a string reads the same backward after removing every non-alphanumeric character and treating uppercase letters as lowercase. Alphanumeric means English letters and decimal digits. If filtering leaves no characters, the result is a palindrome.

bool isPalindrome(string s);

Examples

Input: s = "No 'x' in Nixon!"
Output: true

Its normalized form is noxinnixon.

Input: s = "0P"
Output: false

Digits are retained; 0p is not symmetric.

Constraints

  • The length is between 1 and 200000.
  • Every character is printable ASCII.