(LeetCode) Reverse String

Reverse String

  • 분류 : String
  • 난이도 : Easy

Problem

Write a function that reverses a string. The input string is given as an array of characters s.

Example 1

1
2
Input: s = ["h","e","l","l","o"]
Output: ["o","l","l","e","h"]

Example 2

1
2
Input: s = ["H","a","n","n","a","h"]
Output: ["h","a","n","n","a","H"]

Constraints

Solution

Exapnder
1
2
3
4
5
class Solution {
fun reverseString(s: CharArray): Unit {
s.reverse()
}
}