String Reversal in C++

Easy2 seconds

Implement a function `reverse_string` that takes a string as input and returns the reversed string. **Do not write a main() function; your code will be wrapped automatically.**

Examples:

Input: "hello"
Output: "olleh"

The function should reverse the order of characters.

Input: "world"
Output: "dlrow"

Each character is reversed from its original position.

Constraints:

  • • 1 ≤ s.length ≤ 10^4
  • • s consists of printable ASCII characters
Loading...

Custom Test Input

Press Ctrl + Enter to run

Output

Run your code to see output...