{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "
Write a function that reverses a string. The input string is given as an array of characters char[].
Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory.
\n", "\n", "You may assume all the characters consist of printable ascii characters.
\n", "\n", "\n", "\n", "
Example 1:
\n", "\n", "Input: [\"h\",\"e\",\"l\",\"l\",\"o\"]\n", "Output: [\"o\",\"l\",\"l\",\"e\",\"h\"]\n", "\n", "\n", "
Example 2:
\n", "\n", "Input: [\"H\",\"a\",\"n\",\"n\",\"a\",\"h\"]\n", "Output: [\"h\",\"a\",\"n\",\"n\",\"a\",\"H\"]\n", "\n", "
\n", "Source \n", "