My Java StringBuffer solution


  • 0
    X
    public class Solution {
        public String reverseString(String s) {
           StringBuffer strbuf = new StringBuffer();
            for (int i = s.length() - 1; i > -1; i--){
                strbuf.append(s.charAt(i));
            }
            return strbuf.toString();
        }
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.