Help me in solving Rock, Paper Scissor Problem (Start114)

1 - Created a function that tried to find a winning move.
char getWinningMove(char move) {
if (move == ‘R’) return ‘P’;
if (move == ‘P’) return ‘S’;
if (move == ‘S’) return ‘R’;
return ’ ';
}

2- after that create a function that returns a string resultant winning move
string generateWinningMoves(string s) {
vector winningMoves;

for (char move : s) {
    string winningString;
    for (char opponentMove : s) {
        winningString += getWinningMove(opponentMove);
    }
    winningMoves.push_back(winningString);
}

sort(winningMoves.begin(), winningMoves.end());

return winningMoves[0];

}

where i made a mistake?

Problem Link: Practice Coding Problem - CodeChef

You can’t just sort the result string as the indices of result string is corresponding to the given string
keep in mind that you have to win but in a way so the the string is lexicographically the smallest

Got it…Thanks Ayush