其他分享
首页 > 其他分享> > leetcode344.反转字符串

leetcode344.反转字符串

作者:互联网

开始学习字符串处理了,先来个开胃小菜,秒了!

https://leetcode-cn.com/problems/reverse-string/

class Solution {
    public void reverseString(char[] s) {
        int left = 0, right = s.length - 1;
        char temp;
        while(left < right){
            temp = s[left];
            s[left] = s[right];
            s[right] = temp;
            
            right--;
            left++;
        }
    }
}

标签:right,cn,temp,反转,leetcode344,char,字符串,left
来源: https://blog.csdn.net/qq_37931960/article/details/118994066