LeetCode_Study_Plan/Algorithm
344. Reverse String java
개발하는루루
2022. 12. 20. 23:39
https://leetcode.com/problems/reverse-string/
Reverse String - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
# 투포인터를 이용한 스와핑
class Solution {
public void reverseString(char[] s) {
int left = 0, right = s.length-1;
while (left < right) {
char temp = s[right];
s[right] = s[left];
s[left] = temp;
left++;
right--;
}
}
}