class Solution {
public:
string reversePrefix(string word, char ch) {
int index = word.find(ch);//找到返回index,没找到返回-1
reverse(word.begin(), word.begin() + 1 +index);//翻转0到index之间
return word;
}
};
class Solution {
public:
string reversePrefix(string word, char ch) {
int index = word.find(ch);//找到返回index,没找到返回-1
reverse(word.begin(), word.begin() + 1 +index);//翻转0到index之间
return word;
}
};