add: 220401 [cpp]
This commit is contained in:
parent
fbf88bd6e6
commit
dcded93d5f
|
|
@ -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());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -3,4 +3,4 @@ PROJECT(2204)
|
||||||
|
|
||||||
SET(CMAKE_CXX_STANDARD 23)
|
SET(CMAKE_CXX_STANDARD 23)
|
||||||
|
|
||||||
ADD_EXECUTABLE(2204 220401-CN.cpp)
|
ADD_EXECUTABLE(2204 220401.cpp)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue