Close
Topic list
Reverse the String
EASY
15 mins
Strings
Topics (Covered in this problem)
Problem solved
Skill meter
Strings
-
-
Other topics
Problem solved
Skill meter
Matrices (2D Arrays)
-
-
-
-
Sorting
-
-
Binary Search
-
-
Stacks & Queues
-
-
Trees
-
-
Graph
-
-
Dynamic Programming
-
-
Greedy
-
-
Tries
-
-
Arrays
-
-
SQL
-
-
Binary Search Trees
-
-
Heap
-
-
Bit Manipulation
-
-
Solve problems & track your progress
Checkout your overall progress in every topic here
Become
Sensei
in DSA topics
Open the topic and solve more problems associated with it to improve your skills
Check out the skill meter for every topic
See how many problems you are left with to solve for cracking any stage. Score more than zero to get your progress counted.

# Reverse the String

Contributed by
Sounak Majumder
Easy
0/40
Avg time to solve 15 mins
Success Rate 85 %
Share

## Problem Statement

#### For example:

`````` If the given string is: STR = "abcde". You have to print the string "edcba".
``````
``````Try to solve the problem in O(1) space complexity.
``````
Detailed explanation ( Input/output format, Notes, Constraints, Images )
##### Sample Input 1:
``````3
abcde
coding
hello1
``````
##### Sample Output 1:
``````edcba
gnidoc
1olleh
``````
##### Explanation of the Sample Input 1:
``````For the first test case, STR = "abcde". We need to reverse the string, that is the first element becomes the last element and the last element becomes the first element, the second element becomes the second last element and the second last element becomes the second element and so on. So we get, "edcba".
``````
##### Sample Input 2:
``````3
a
1det@Z
\$1xYuP
``````
##### Sample Output 2
``````a
Z@ted1
PuYx1\$
``````
Auto
Console