Check if a String is a Palindrome

Problem Write a program to check whether a given string is a palindrome — i.e. it reads the same forwards and backwards.

Input / Output

  • Input: a string s.
  • Output: boolean — true if s is a palindrome, false otherwise.

Constraints

  • Length up to ~10^5.
  • The exact character rules depend on the framing: the base version assumes a clean alphanumeric string; the common extension asks for case-insensitive comparison that skips non-alphanumeric characters.
  • O(1) extra space is expected — building a reversed copy is the answer to beat.

Example

  • "madam" → true
  • "hello" → false
  • Tricky cases: "" and "a" are palindromes; "A man, a plan, a canal: Panama" → true under the case-insensitive, punctuation-skipping rule; "0P" → false, which catches solutions comparing raw ASCII without checking alphanumeric class.
asked …
LeaderboardSalaryAccount