标签:
Write a function that takes a string as input and returns the string reversed.
Example:
Given s = "hello", return "olleh".
Subscribe to see which companies asked this question
1 public class Solution { 2 public String reverseString(String s) { 3 if(s == null || s.length() <=1) return s; 4 StringBuffer res = new StringBuffer(s.length()); 5 for(int i = s.length()-1;i >=0 ;i--){ 6 res.append(s.charAt(i)); 7 } 8 return res.toString(); 9 } 10 }
344. Reverse String Java Solutions
标签:
原文地址:http://www.cnblogs.com/guoguolan/p/5450795.html