class Solution {
public:
string reversePrefix(string word, char ch) {
int n=word.size();
int r=0;
for(int i=0;i<n;i++)
{
if(word[i]!=ch)
{
r++;
}
else break;
}
if(r==n) return word; reverse(word.begin(),word.begin()+r+1);
return word;
}
};