294. Reverse a String I
Given an input string as an array of characters, write a function that reverses the string.
Example 1:
Input : s = ["h", "e", "l", "l", "o"]
Output : ["o", "l", "l", "e", "h"]
Explanation : The given string is s = "hello" and after reversing it becomes s = "olleh".
Example 2:
Input : s = ["b", "y", "e" ]
Output : ["e", "y", "b"]
Explanation : The given string is s = "bye" and after reversing it becomes s = "eyb".
Now Your Turn!
Pick the correct output for the given inputInput : s = ["h", "a", "n", "n", "a", "h"]
Still unsure what the problem is asking ?
Let’s go through a few more examples, step by step, to make it clearer.
Constraints:
- 1 <= s.length <= 103
- s consist of only lowercase and uppercase English characters.