add: 220202-CN

This commit is contained in:
Lam Haoyin 2022-02-02 10:31:51 +08:00
parent 8a7e8c00e8
commit ca2536a1f7
No known key found for this signature in database
GPG Key ID: 8C089CB1A2B7544F
2 changed files with 16 additions and 1 deletions

15
2202/220202-CN.cpp Normal file
View File

@ -0,0 +1,15 @@
#include <string>
#include <iostream>
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;
}

View File

@ -3,4 +3,4 @@ PROJECT(2202)
SET(CMAKE_CXX_STANDARD 23) SET(CMAKE_CXX_STANDARD 23)
ADD_EXECUTABLE(2202 220201.cpp) ADD_EXECUTABLE(2202 220202-CN.cpp)