dsa · easy

Reverse String

GreyOrangeStringTwo PointersFoundation

Reverse a list of characters **in place** and return it.

Arguments

**Example:** ["h","e","l","l","o"]["o","l","l","e","h"].

Constraints

1 <= s.length <= 10^5 Hidden tests include near-max size for this bound; a slower-than-intended solution TLEs.

Examples

Example 1

Input:
["h","e","l","l","o"]

Expected:
["o","l","l","e","h"]

Example 2

Input:
["H","a"]

Expected:
["a","H"]

Open in the Dojo editor