Problem · String

Reverse a String

Learn this problem
EasyIndiaMARTONSITE INTERVIEW

Problem statement

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

Character case and all non-letter characters must be preserved.

Function

reverseString(s: String) → String

Examples

Example 1

s = "FastPrep"return = "perPtsaF"

Reading the input from right to left produces perPtsaF.

Example 2

s = "hello"return = "olleh"
drafts saved locally
public String reverseString(String s) {
  // write your code here
}
s"FastPrep"
expected"perPtsaF"
checking account