Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- string predictPartyVictory(string senate) {
- queue<int>dq, rq;
- int n = senate.size();
- for(int i =0 ;i < n;i++)
- {
- if(senate[i] == 'R'){
- rq.push(i);
- }
- else{
- dq.push(i);
- }
- }
- while(!dq.empty() && !rq.empty())
- {
- int ri = rq.front();
- rq.pop();
- int di = dq.front();
- dq.pop();
- if(ri < di)
- {
- rq.push(ri+n);
- }
- else{
- dq.push(di+n);
- }
- }
- if(dq.empty())
- return "Radiant";
- else
- return "Dire";
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement