add: 220401 [cpp]

This commit is contained in:
Lam Haoyin 2022-04-01 17:10:47 +08:00
parent fbf88bd6e6
commit dcded93d5f
No known key found for this signature in database
GPG Key ID: 8C089CB1A2B7544F
2 changed files with 16 additions and 1 deletions

15
cpp/2204/220401.cpp Normal file
View File

@ -0,0 +1,15 @@
#include <vector>
#include <algorithm>
/**
* 344. Reverse String
* 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.
*/
class Solution {
public:
static void reverseString(std::vector<char>& s) {
std::reverse(s.begin(), s.end());
}
};

View File

@ -3,4 +3,4 @@ PROJECT(2204)
SET(CMAKE_CXX_STANDARD 23)
ADD_EXECUTABLE(2204 220401-CN.cpp)
ADD_EXECUTABLE(2204 220401.cpp)