题目地址
解题思路
没什么思路,这道题就很简单
代码实现(C++)
class Solution {
public:
string reversePrefix(string word, char ch)
{
for(int i=0;i<word.size();i++)
{
if(ch==word[i])
{
for(int head=0,tail=i;head<=tail;)
{
int temp=word[head];
word[head]=word[tail];
word[tail]=temp;
head++;
tail--;
}
break;
}
}
return word;
}
};