My approch =“If the i-th element of string is equal to the R then x is increment by 1 else decrement it by1 and the x-th element of vector v is equal to x and output non-zero element in the vector…”
My code:-
/~~~/Jai Shree Ram
#include<math.h>
include
#include<string.h>
include
include <bits/stdc++.h>
include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
/~~~~~~~/What’s Up
#ifdef LOCAL
include “algo/debug.h”
#else
define debug(…) 42
#endif
/~~~~~/Radhe Radhe
define PYes cout<<“Yes\n”
define PNo cout<<“No\n”
define PYES cout<<“YES\n”
define PNO cout<<“NO\n”
/~~~~/Hare krishna
define in it n;cin>>n;
define sin string s;cin>>s;
define print(num) cout<<num<<endl;
define vec(v) vectorv;
/~~/Jiwanshu chaudhary
define it long long int
define loop(n) for(it i=0;i<n;i++)
define all(V) V.begin(),V.end()
define f for(auto &ele : V)
/~/Har Har Mahadev
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);
it t; cin >> t;
for(it _ = 0 ; _ < t ; _ += 1)
{
it n,x;string s; vector<it>V(100);
cin>>n>>x>>s; V[x]=x;
for(it i=0;i<n;i++){
if(s[i]=='R')
{
x++;
V[x]=x;
}
else
{
x--;
V[x]=x;
}
}
cout<<100-count(all(V),0)<<endl;
}
return 0;
}
/Ek Dastak Pe Wo, Darwaaza Nahin Kholega,
Usey Maloom Jo Hai, Main Ne Khade Rehna Hai./