Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Reverse a String of Letters

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

Your question is Reverse a String of Letters. 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

Mercury Insurance systems may need to reverse short text values for validation or display utilities. Given a string containing letters, return a new string with the characters in reverse order.

Formal Specification

Implement reverse_letters(s), where s is a string containing zero or more English alphabetic characters. Return a string containing the same characters in reverse order. Preserve each character exactly, including its case. The input string must not be modified, which is naturally satisfied because Python strings are immutable.

Constraints

  • 0 <= len(s) <= 10^5
  • s contains only English alphabetic characters
  • The input may be empty
  • The output contains the same characters in reverse order

Function Signature

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