In AirBrush, you need a utility function to check whether a caption reads the same forward and backward. Write a function that returns True if a given string is a palindrome and False otherwise.
A palindrome should be checked exactly as given, meaning character case, spaces, and punctuation are all treated as normal characters.
sTrue if s is identical to its reverseFalse otherwiseExample 1
s = "level"TrueExample 2
s = "Air Apps"False0 <= len(s) <= 10^5s may contain letters, digits, spaces, and punctuationTry to solve this in linear time. A two-pointer approach is preferred because it avoids building a full reversed copy of the string.
s = "level"OutputTrueWhyThe characters match symmetrically: `l==l`, `e==e`, and the middle character does not affect the result.s = "abca"OutputFalseWhyThe first and last characters match, but `b` and `c` do not, so the string is not a palindrome.s = "a a"OutputTrueWhySpaces are treated as regular characters, and the string is still identical to its reverse.0 <= len(s) <= 10^5s consists of printable charactersCase, spaces, and punctuation are treated as normal charactersdef is_palindrome(s):