@@ -0,0 +1,1100 @@
+package string;%0A%0Apublic class ReverseString %7B%0A%0A    //Difficulty: Easy%0A    //TAG: Apple%0A    //TAG: String%0A%0A    /**%0A     * 344. Reverse String%0A     * Write a function that reverses a string. The input string is given as an array of characters char%5B%5D.%0A     *%0A     * Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory.%0A     *%0A     * You may assume all the characters consist of printable ascii characters.%0A     *%0A     *%0A     *%0A     * Example 1:%0A     *%0A     * Input: %5B%22h%22,%22e%22,%22l%22,%22l%22,%22o%22%5D%0A     * Output: %5B%22o%22,%22l%22,%22l%22,%22e%22,%22h%22%5D%0A     * Example 2:%0A     *%0A     * Input: %5B%22H%22,%22a%22,%22n%22,%22n%22,%22a%22,%22h%22%5D%0A     * Output: %5B%22h%22,%22a%22,%22n%22,%22n%22,%22a%22,%22H%22%5D%0A     */%0A%0A    /*%0A    Solution:%0A    exchange left and right and move them to middle%0A%0A    Time: O(n/2) = O(n)%0A    Space: O(1)%0A     */%0A%0A    public void reverseString(char%5B%5D s) %7B%0A        if (s == null) return;%0A        int l = 0, r = s.length - 1;%0A        while (l %3C r) %7B%0A            char temp = s%5Bl%5D;%0A            s%5Bl%5D = s%5Br%5D;%0A            s%5Br%5D = temp;%0A            l++;%0A            r--;%0A        %7D%0A    %7D%0A%0A%7D%0A

344. Reverse String