All problems

Problem 46

Reverse a String

Easy · 10 pts · String, Two Pointers

Problem

You are given a string S of lowercase English letters. Print S reversed, so that its last character comes first and its first character comes last. You can build the reversed string from the end backwards, or swap characters in place from both ends towards the middle. Many languages also have a built-in reverse, but it is worth knowing how to do it by hand.

Input

A single string S of lowercase English letters.

Output

Print S reversed.

Constraints

1 <= |S| <= 100000

Example input

hello

Example output

olleh

Explanation

Reading "hello" from its last character to its first gives o, l, l, e, h, so the output is olleh.

Every problem here can be used in a RelayTrixCode team match. Create a room.

Previous: Minimum Size Subarray Sum Next: Count Vowels and Consonants