Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

String Reversal Function

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

Your question is String Reversal Function. 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

UMass Boston WISER displays short notification messages that may need to be rendered in reverse for a formatting test. Write a function that returns the characters in a message in reverse order.

Formal Specification

Implement reverse_wiser_message(message).

  • Input: message, a Python string.
  • Output: A new string containing the same characters in reverse order.
  • Preserve every character exactly, including spaces, punctuation, digits, and Unicode characters.

Python strings are immutable, so build a mutable character list, reverse it with two pointers, then join it into the result.

Constraints

  • 0 <= len(message) <= 100,000
  • message may contain letters, digits, whitespace, punctuation, and Unicode code points
  • Return a new string
  • Reverse by Python character positions

Function Signature

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