FastPrepReverse a String
Problem · String

Reverse a String

Learn this problem
EasyFlexTrade logoFlexTradeFULLTIMEOA

Problem statement

Given a string s, return a new string containing the same characters in reverse order.

Preserve character case, spaces, digits, and punctuation. An empty input returns an empty string.

Function

reverseString(s: String) → String

Examples

Example 1

s = "FastPrep"return = "perPtsaF"

Reading FastPrep from right to left produces perPtsaF.

Example 2

s = "a b!"return = "!b a"

The punctuation and space remain characters and move to their reversed positions.

Example 3

s = ""return = ""

The reverse of the empty string is the empty string.

Constraints

  • 0 <= s.length <= 200000
  • s contains only printable ASCII characters.

More FlexTrade problems

drafts saved locally
public String reverseString(String s) {
  // Write your code here.
}
s"FastPrep"
expected"perPtsaF"
checking account