Check If a Sentence Reads the Same Ignoring Case and Symbols

Implement isSentencePalindrome

Given a string s that may contain letters, digits, spaces, and punctuation, determine whether it reads the same forwards and backwards once you ignore case and skip every character that isn't a letter or a digit. Try to solve it by scanning inward from both ends of the original string at once, rather than building a cleaned copy first — that gets you to O(1) extra space.

Example 1:

Input: s = "No lemon, no melon!"

Output: true

Example 2:

Input: s = "Was it a car or a cat I saw?"

Output: true

Example 3:

Input: s = "Hello, World!"

Output: false

+ 6 hidden test cases run on Submit.

Constraints:

  • 1 ≤ s.length ≤ 200
  • s consists of printable ASCII characters — letters, digits, spaces, and punctuation

s =

No lemon, no melon!