Easy one line java with StringBuffer


  • 0
    R

    We can use StringBuffer to return the value

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

    it's maybe the simplest solution


Log in to reply
 

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