FastPrepReverse A String
Problem · String

Reverse A String

Learn this problem
EasyNvidia logoNvidiaFULLTIMEONSITE INTERVIEW

Problem statement

You are given a string s consisting of printable ASCII characters.

Return a new string whose characters are the characters of s in reverse order.

The empty string reverses to the empty string.

Function

reverseString(s: String) → String

Examples

Example 1

s = "hello"return = "olleh"

Reading hello from right to left produces olleh.

Example 2

s = "a"return = "a"

A single character is already reversed.

Constraints

  • 0 <= s.length <= 10^5.
  • s contains only printable ASCII characters.

More Nvidia problems

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