We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents ec53e86 + e421d8a commit 2b3c05cCopy full SHA for 2b3c05c
#649. Dota2 Senate.cpp
@@ -0,0 +1,25 @@
1
+class Solution {
2
+public:
3
+ string predictPartyVictory(string senate) {
4
+ int n=senate.size();
5
+ queue<int> de;
6
+ queue<int> re;
7
+ for(int i=0;i<n;i++){
8
+ if(senate[i]=='R')
9
+ re.push(i);
10
+ else
11
+ de.push(i);
12
+ }
13
+ while(!de.empty()&&!re.empty()){
14
+ int di=de.front();
15
+ int ri=re.front();
16
+ if(ri>di)
17
+ de.push(di+n);
18
19
+ re.push(ri+n);
20
+ de.pop();
21
+ re.pop();
22
23
+ return de.empty()?"Radiant":"Dire";
24
25
+};
0 commit comments