FastPrepReverse A String
Problems/Reverse A String

Reverse A String

NVIDIA logoNVIDIA● EasyFULLTIMEONSITE INTERVIEW
QuestionFunctionExamplesConstraints

Problem statement

Source note: The report asked to reverse a string. The judged core task matches the visible source at about 99%; encoding, in-place vs new buffer, and examples are specified for practice.

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

  • Summarize Server Healthcheck LogsPHONE SCREEN · Seen Oct 2026
  • Query a Header-Encoded MatrixOA · Seen Oct 2026
  • Maximum ScoreOA · Seen Oct 2026
All NVIDIA interview questionsSee NVIDIA hiring insights
Saved
class Solution {
    public String reverseString(String s) {
      // Write your code here.
    }
}
Checking account…