Taking advantage of StringBuilder - simple

  • 0

    Since most solutions listed below already cover techniques like 1) two pointers starting at either end, swapping, then converging in the middle, 2) using a stack-based implementation, 3) using recursion, etc., here is a simple one that takes advantage of Java's built-in StringBuilder class.

    public class Solution {
        public String reverseString(String s) {
            StringBuilder result = new StringBuilder(s);
            return result.reverse().toString();

Log in to reply

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