Under my umbrella.

SKII

Less is more.

力扣题解 344th 反转字符串

344th 反转字符串

  • 双指针法

    双指针法是非常常用的算法,也很容易理解。

    class Solution {
        public void reverseString(char[] s) {
            int i = 0, j = s.length - 1;
            while(i <= j) {
                char t = s[i];
                s[i] = s[j];
                s[j] = t;
                i++;
                j--;
            }
        }
    }
    
posted @ 2020-07-04 21:06  NLYang  阅读(125)  评论(0编辑  收藏  举报