PythonEasyStrings10 min

Reverse a string

Preserve spaces and case. The input consists of one ASCII line, which may be empty. Interviewers use this problem to assess use a negative slice step to traverse characters backwards.

Input

One line containing the string.

Output

Print the result on one line; print an empty line for an empty string.

Constraints

0 <= length <= 100000.

Example

Input

automation

Output

noitamotua

Example 2 input

racecar

Output

racecar

A palindrome is unchanged by reversal.

Public test cases (2)

  • Input

    automation

    Expected output

    noitamotua
  • Input

    a b c

    Expected output

    c b a
Hints (2)
  1. Identify the state needed to avoid repeated work.
  2. Use a negative slice step to traverse characters backwards.

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

Your solution

Checking runner availability…

Reference solution

Sign in for solution
All Python programs