Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Valid Palindrome and String Reverse

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

Your question is Valid Palindrome and String Reverse. 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

Antra's coding evaluation utility needs to identify whether an input string is a palindrome. Given a string s, return True if it reads the same from left to right and right to left, otherwise return False.

The comparison is exact: preserve character case, whitespace, punctuation, and all other characters. An empty string and a single-character string are palindromes.

Formal Specification

  • Input: s, a string containing zero or more characters.
  • Output: A Boolean value. Return True when s equals its reverse, and False otherwise.
  • Implement the check without modifying the input string.

Constraints

  • 0 <= len(s) <= 10^5
  • s may contain letters, digits, whitespace, punctuation, or Unicode characters
  • Comparison is case-sensitive
  • Non-alphanumeric characters are not ignored

Function Signature

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