diff --git a/cpp/2204/220401.cpp b/cpp/2204/220401.cpp new file mode 100644 index 0000000..7586cd7 --- /dev/null +++ b/cpp/2204/220401.cpp @@ -0,0 +1,15 @@ +#include +#include + +/** + * 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& s) { + std::reverse(s.begin(), s.end()); + } +}; diff --git a/cpp/2204/CMakeLists.txt b/cpp/2204/CMakeLists.txt index 1610c1f..67a70c6 100644 --- a/cpp/2204/CMakeLists.txt +++ b/cpp/2204/CMakeLists.txt @@ -3,4 +3,4 @@ PROJECT(2204) SET(CMAKE_CXX_STANDARD 23) -ADD_EXECUTABLE(2204 220401-CN.cpp) +ADD_EXECUTABLE(2204 220401.cpp)