-
344. Reverse String javaLeetCode_Study_Plan/Algorithm 2022. 12. 20. 23:39
https://leetcode.com/problems/reverse-string/
# 투포인터를 이용한 스와핑
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--; } } }
'LeetCode_Study_Plan > Algorithm' 카테고리의 다른 글
876. Middle of the Linked List java (0) 2022.12.21 🎵 557. Reverse Words in a String III java (0) 2022.12.20 167. Two Sum II - Input Array Is Sorted java (0) 2022.12.20 283. Move Zeroes java (0) 2022.12.20 🎵 189. Rotate Array java (0) 2022.12.20