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.
1 parent 30694a1 commit 668c150Copy full SHA for 668c150
649-dota2-senate.js
@@ -0,0 +1,27 @@
1
+/**
2
+ * @param {string} senate
3
+ * @return {string}
4
+ */
5
+const predictPartyVictory = function (senate) {
6
+ const m = senate.length,
7
+ radiant = [],
8
+ dire = []
9
+ for (let i = 0; i < m; i++) {
10
+ if (senate[i] === 'R') {
11
+ radiant.push(i)
12
+ } else {
13
+ dire.push(i)
14
+ }
15
16
+
17
+ while (radiant.length && dire.length) {
18
+ let r = radiant.shift(),
19
+ d = dire.shift()
20
+ if (r < d) {
21
+ radiant.push(r + m)
22
23
+ dire.push(d + m)
24
25
26
+ return radiant.length > dire.length ? 'Radiant' : 'Dire'
27
+}
0 commit comments