PythonEasyStrings10 min

Check whether a string is a palindrome

Compare characters exactly, including spaces and letter case. The empty string is a palindrome. Interviewers use this problem to assess move two pointers inward and stop on the first mismatch.

Input

One ASCII line.

Output

Print true or false in lowercase.

Constraints

0 <= length <= 100000.

Example

Input

racecar

Output

true

Example 2 input

a a

Output

true

Spaces participate in the comparison.

Public test cases (2)

  • Input

    racecar

    Expected output

    true
  • Input

    Python

    Expected output

    false
Hints (2)
  1. Identify the state needed to avoid repeated work.
  2. Move two pointers inward and stop on the first mismatch.

Target complexity: time O(n) · space O(1)

Your solution

Checking runner availability…

Reference solution

Sign in for solution
All Python programs