Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

String Reverse Explanation

EasyPython00:00
Practice interviewer
In session
5 left
00:00

Your question is String Reverse Explanation. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

X Development processes user-entered labels that sometimes need to be displayed in reverse order. Given a string, return a new string containing the same characters in reverse order.

Formal Specification

Implement reverse_string(s), where s is a Python string. Return a string whose characters appear in the opposite order. The input may contain letters, digits, spaces, punctuation, and Unicode characters. Do not modify the original string, since Python strings are immutable.

You may use standard Python string or sequence operations. The result must contain every input character exactly once, in reverse positional order.

Constraints

  • 0 <= len(s) <= 10^5
  • The input is a valid Python string
  • Preserve every character, including spaces and punctuation
  • Return an empty string for empty input

Function Signature

def reverse_string(s):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output