4 Line Java Code


  • 0
    E
    public class Solution {
        public String reverseString(String s) {
            StringBuilder sb=new StringBuilder();
            for(char ch:s.toCharArray()){
                sb.insert(0,ch);
            }
            return sb.toString();
        }
    }
    

Log in to reply
 

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