
In the Zumper mobile app, some text-processing utilities need to reverse user-entered strings. Write a function that takes a string and returns a new string with its characters in reverse order.
ss in reverse orderExample 1
s = "zumper""repmuz"Example 2
s = "Rent""tneR"0 <= len(s) <= 10^5s may contain letters, digits, spaces, and punctuationAim for a linear-time solution. You may solve this with Python string slicing or by building the result manually with two pointers or iteration.
s = "zumper"Output"repmuz"WhyReading the string from the last character to the first gives `repmuz`.s = "Rent"Output"tneR"WhyThe order is reversed, but each character keeps its original casing.s = "a b!"Output"!b a"WhySpaces and punctuation are treated like normal characters and are also reversed.0 <= len(s) <= 10^5s may contain letters, digits, spaces, and punctuationThe function should return a new stringAim for O(n) timedef reverse_string(s):