Easy to understand java solution.


  • 0
    J

    public class Solution {
    public String reverseString(String s)
    {
    char [] word = new char[s.length()];
    for(int i = s.length() - 1, j = 0; i >= 0 && j < s.length(); i--, j++)
    {
    word[j] = s.charAt(i);
    }
    return String.valueOf(word);
    }
    }


Log in to reply
 

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