Dataford
Interview Guides
Upgrade
All questions/Coding/Check Palindrome String

Check Palindrome String

Easy
Coding
Asked at 1 company1StringsTwo Pointers
Also asked at
B

Problem

Determine whether a given string is a palindrome. Return true if it reads the same forward and backward; otherwise return false.

Examples

Example 1
Inputs = "racecar"OutputtrueWhyAll mirrored characters match.
Example 2
Inputs = "hello"OutputfalseWhyThe string differs when reversed.

Constraints

  • `0 <= len(s) <= 10^5`
  • `s` contains ASCII characters
  • Use exact character comparison

Problem

Determine whether a given string is a palindrome. Return true if it reads the same forward and backward; otherwise return false.

Examples

Example 1
Inputs = "racecar"OutputtrueWhyAll mirrored characters match.
Example 2
Inputs = "hello"OutputfalseWhyThe string differs when reversed.

Constraints

  • `0 <= len(s) <= 10^5`
  • `s` contains ASCII characters
  • Use exact character comparison
Practice Python
Python 3.10
Open on desktop for the full Python editor with syntax highlighting and autocomplete.