Reverse the String Problem Statement

You are given a string STR which contains alphabets, numbers, and special characters. Your task is to reverse the string.

Example:

Input:
STR = "abcde"
Output:
"edcba"

Input:

The first line of input contains a single integer 'T', representing the number of test cases.
Each test case consists of one line containing the string 'STR'.

Output:

For each test case, output the reversed string of 'STR'. Each result must be printed on a new line.

Example:

Input:
2
hello
world!
Output:
olleh
!dlrow

Constraints:

  • 1 ≤ T ≤ 10
  • 1 ≤ |STR| ≤ 10^5, where |STR| is the length of the string STR.
  • Time limit: 1 second.

Note:

Just implement the function; you do not need to print anything.

AnswerBot
4mo

Reverse a given string containing alphabets, numbers, and special characters.

  • Iterate through the string from the end to the beginning and append each character to a new string.

  • Use built-in functions l...read more

Anonymous
2mo
s = "hello" reversed_s = s[::-1] print(reversed_s) # Output: "olleh" built-in functions- s = "hello" reversed_s = ''.join(reversed(s)) print(reversed_s) # Output: "olleh"
Help your peers!
Select
Add answer anonymously...

Ericsson Software Developer interview questions & answers

A Software Developer was asked 6mo agoQ. What is your background?
A Software Developer was asked 10mo agoQ. Write a program to swap two variables without using a third variable.
A Software Developer was asked 10mo agoQ. What is method overloading and overriding?

Popular interview questions of Software Developer

A Software Developer was asked 10mo agoQ1. Write a program to swap two variables without using a third variable.
A Software Developer was asked 10mo agoQ2. What is method overloading and overriding?
A Software Developer was asked Q3. Describe the call flow.
Ericsson Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits