题目链接
题解
rt
class Solution {
public:
string reversePrefix(string word, char ch) {
string s = "";
int i = 0;
for(;i<word.length();i++)
{
s.push_back(word[i]);
if(word[i] == ch) break;
}
if(i == word.length()) return s;
reverse(s.begin(), s.end());
return s + word.substr(i+1, word.length() - (i+1));
}
};