Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Validate Palindrome in Chat Input

EasyPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Validate Palindrome in Chat Input. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

In an OpenAI chat surface, some validation checks may need to determine whether a user-provided string reads the same forward and backward. Write a function that returns True if a string is a palindrome and False otherwise.

A palindrome is a string that is identical when reversed. For this problem, compare characters exactly as given: do not ignore spaces, punctuation, or letter casing.

Formal Specification

  • Input: a string s
  • Output: a boolean indicating whether s is a palindrome

Constraints

  • 0 <= len(s) <= 10^5
  • s contains printable ASCII characters
  • Comparison is exact: do not ignore spaces, punctuation, or case

Function Signature

def is_palindrome(s):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output