Java StringBuilder solution


  • 0
    P

    // return new StringBuilder(s).reverse().toString();
    StringBuilder output = new StringBuilder();
    char[] a = s.toCharArray();

    for (int i=a.length-1; i>=0; i--){
        
        output = output.append(a[i]); 
    } 
        
        
        return output.toString();

Log in to reply
 

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