My issue
please anyone check my code
as it shown only one test case as pass
My code
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int t;cin>>t;
while(t--){
int n;cin>>n;
string A;cin>>A;
vector<char> ans(n,'P');
int ct =0;
int a= n/2 + 1;
for(int i=0; i<n && ct<=((n+2)/2); i++){
if(A[i]=='R'){
ct++;
}
}
for(int i=n-1; i>0 && ct<((n+2)/2); i--){
if(A[i] == 'S' && ct<((n+2)/2)){
ans[i]='R';
ct++;
}
if(A[i]=='P' && ct<((n+2)/2)){
ans[i]='S';
ct++;
}
}
// for(int i=0; i<n && ct<((n+2)/2); i++){
// if(A[i]=='P'){
// ans[i]='S';
// ct++;
// }
// }
for(auto it:ans)cout<<it;
cout<<endl;
}
//cout<<(-9)%19;
return 0;
}
Problem Link: Rock-Paper-Scissors Practice Coding Problem - CodeChef