首页 > 代码库 > leetcode 344. Reverse String

leetcode 344. Reverse String

要求:将给定字符串内容倒置。

  例:输入"Hello"  输出"olleH" 

 1 public class Solution {
 2     public String reverseString(String s) {
 3         int len = s.length();
 4         char []s1 = new char[len];   
 5         for(int i = 0;i < len;i++){
 6             s1[i] = s.charAt(len-1-i);
 7         }
 8         String result = new String(s1);
 9         return result;
10     }
11 }

 

leetcode 344. Reverse String