We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 132d5f1 commit 2c20320Copy full SHA for 2c20320
649. Dota2 参议院.js
@@ -0,0 +1,27 @@
1
+/**
2
+ * @param {string} senate
3
+ * @return {string}
4
+ */
5
+var predictPartyVictory = function (senate) {
6
+ const r = [];
7
+ const d = [];
8
+ for (let i = 0; i < senate.length; i++) {
9
+ if (senate[i] === 'R') {
10
+ r.push(i);
11
+ } else {
12
+ d.push(i);
13
+ }
14
15
+ while (r.length && d.length) {
16
+ if (r[0] < d[0]) {
17
+ r.push(r[0] + senate.length);
18
19
+ d.push(d[0] + senate.length);
20
21
+ r.shift();
22
+ d.shift();
23
24
+ return r.length ? 'Radiant' : 'Dire';
25
+};
26
+
27
+console.log(predictPartyVictory("RDD"));
0 commit comments