Skip to content

Commit 2b3c05c

Browse files
authored
Merge pull request #89 from InflixOP/patch1
Create #649. Dota2 Senate.cpp
2 parents ec53e86 + e421d8a commit 2b3c05c

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

#649. Dota2 Senate.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
else
19+
re.push(ri+n);
20+
de.pop();
21+
re.pop();
22+
}
23+
return de.empty()?"Radiant":"Dire";
24+
}
25+
};

0 commit comments

Comments
 (0)