728x90
344. Reverse String
-
[LeetCode] 344. Reverse String c++Coding Test/LeetCode 2022. 12. 26. 16:49
문제 Write a function that reverses a string. The input string is given as an array of characters s. You must do this by modifying the input array in-place with O(1) extra memory. Input: s = ["h","e","l","l","o"] Output: ["o","l","l","e","h"] input으로 주어지는 벡터 s의 요소들의 순서를 반대로 뒤집는 문제입니다. 문제 해결 class Solution { public: void reverseString(vector& s) { reverse(s.begin(), s.end()); } }; 다른 풀이 class Solut..