Reverse String

Reverse String

Easy Programming Interview Data Structures 20 views
Explanation Complexity

Problem Statement

Input is a single string s is provided (no trailing spaces needed). Output the reversed string.

Input Format

One line s.

Output Format

One line reversed.

Example

abcd
dcba

Constraints

Length

Input / Output Format

Input Format
One line s.
Output Format
One line reversed.
Constraints
Length

Examples

Input:
abcd
Output:
dcba

Example Solution (Public)

Programming Interview
import sys
s=sys.stdin.read()
if s is None: sys.exit(0)
if s.endswith('\
'):
  s=s[:-1]
sys.stdout.write(s[::-1])

Official Solution Code

import sys
s=sys.stdin.read()
if s is None: sys.exit(0)
if s.endswith('\
'):
  s=s[:-1]
sys.stdout.write(s[::-1])
Please login to submit solutions.
Editor
Output

                                        
Please login to submit solutions.