
本文共 3236 字,大约阅读时间需要 10 分钟。
������������Java���������������������������
������������������������������������������������������������������������������������������������������������������������������������������������������������Java������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
���������������������
���������������������
public class Solution { public void reverseString(char[] s) { int i, len = s.length; Character ch; for(i=0; i }}
������������������������������������������������������������������������������������������������������������������������
������������������������
- ���
Solution
������������������������������������������ - ������
reverseString
������������������������������char[] s
���������������������������������������
������������
len
������������������������������������������Character ch
���������������������������������������������������������������������������������
������������
- ������������
i
���0
������������������������������i
������������������ - ������������������������������������������������������������������
������������������������������������������������������������������������������������������������������������������������
���������������������
������������������������������������������������������������������������������������������������
���������������������
Character ch
������������������������������������������������������������
���������������������������
- ���������������
i
������������������������������������������
������������������
- ������������������������������������������������������������
- ���������������������������������������������������������������
���������������������������
public class Solution { 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--; } }}
������������������
���������������������������������������������������
���������������
- ������������������������������������������������������������������
i
���j
���������������������������������������������
������������
- ���������������������������������������������������������������������������O(n)������������������
- ������������������������������������������������
������������������
- ���������������������
ch
��������������������������������� - ���������������������������������������������������������������
���������������������������
������������������������������������������������������������������������������������������������������������������������
- Web���������������������������������������-������������������������������������������-���������������������������������������
������
���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
发表评论
最新留言
关于作者
