字符串1-反转字符串

题目网址:https://leetcode.cn/leetbook/read/top-interview-questions-easy/xnhbqj/

public class Solution {
    public void ReverseString(char[] s) {
        int len = s.Length;
        for(int i = 0; i < len / 2; i++)
        {
            char k = s[i];
            s[i] = s[len - 1 - i];
            s[len - 1 - i] = k;
        }
    }
}

猜你喜欢

转载自blog.csdn.net/oyqho/article/details/130026570