ReverseString

2022-12-14 浏览 (677)

ReverseString.java 源码

package algorithm.string.leetcode;

/**
 * @author roseduan
 * 反转字符串
 */
public class ReverseString {

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

你可能感兴趣的文章

IsomorphicStrings

ReverseOnlyLetters

ReverseWordsInString

  • 所属分类: 后端技术
  • 本文标签: 技术
  • 版权声明: 本文链接 https://seaxiang.com/blog/fafd43ceb9a34ec69a2028e9bd6c6828