LeetCode: 344. 反转字符串
双指针
class Solution {
public void reverseString(char[] s
) {
int start
= 0;
int end
= s
.length
- 1;
while (start
<= end
){
char temp
= s
[start
];
s
[start
] = s
[end
];
s
[end
] = temp
;
start
++;
end
--;
}
}
}
转载请注明原文地址:https://blackberry.8miu.com/read-41059.html