Skip to content

Latest commit

 

History

History
24 lines (16 loc) · 430 Bytes

README.md

File metadata and controls

24 lines (16 loc) · 430 Bytes

Description

Write a function that takes a string as input and returns the string reversed.

Example: Given s = "hello", return "olleh".

思路

使用 StringBuilder 的 reverse 方法。

实现代码

class Solution {
  public String reverseString(String s) {
    return new StringBuilder(s).reverse().toString();
  }
}