leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

0649.cpp (517B)


0 class Solution {
1 public:
2 string predictPartyVictory(string senate) {
3 queue<int> rq, dq;
4 int n = senate.size();
6 for (int i = 0; i < n; i++)
7 (senate[i] == 'R' ? rq : dq).push(i);
9 while (!rq.empty() && !dq.empty()) {
10 int a = rq.front(), b = dq.front();
11 rq.pop(), dq.pop();
12 if (a < b)
13 rq.push(a + n);
14 else
15 dq.push(b + n);
16 }
18 return rq.size() ? "Radiant" : "Dire";
19 }
20 };