From ca2536a1f76b37fd913050992a93a7c8c2a255b3 Mon Sep 17 00:00:00 2001 From: Lam Haoyin Date: Wed, 2 Feb 2022 10:31:51 +0800 Subject: [PATCH] add: 220202-CN --- 2202/220202-CN.cpp | 15 +++++++++++++++ 2202/CMakeLists.txt | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 2202/220202-CN.cpp diff --git a/2202/220202-CN.cpp b/2202/220202-CN.cpp new file mode 100644 index 0000000..1379285 --- /dev/null +++ b/2202/220202-CN.cpp @@ -0,0 +1,15 @@ +#include +#include + +class Solution { +public: + static std::string reversePrefix(std::string word, char ch) { + std::reverse(word.begin(), std::next(word.begin(), 1 + word.find(ch))); + return word; + } +}; + +int main() { + std::cout << Solution::reversePrefix("xyxzxe", 'z'); + return 0; +} diff --git a/2202/CMakeLists.txt b/2202/CMakeLists.txt index 75b30db..cb0e1e3 100644 --- a/2202/CMakeLists.txt +++ b/2202/CMakeLists.txt @@ -3,4 +3,4 @@ PROJECT(2202) SET(CMAKE_CXX_STANDARD 23) -ADD_EXECUTABLE(2202 220201.cpp) +ADD_EXECUTABLE(2202 220202-CN.cpp)