package leetcode;

/**
 * https://leetcode.com/problems/dota2-senate/
 */
public class Problem649 {
    public String predictPartyVictory(String senate) {
        // TODO
        return null;
    }

    public static void main(String[] args) {
        Problem649 prob = new Problem649();
        System.out.println(prob.predictPartyVictory("RD")); // Radiant
        System.out.println(prob.predictPartyVictory("RDD")); // Dire
        System.out.println(prob.predictPartyVictory("RDRD")); // Radiant
        System.out.println(prob.predictPartyVictory("RDDR")); // Radiant
    }
}

@@ -12,16 +12,116 @@
 tcode;%0A%0A
+import java.util.ArrayList;%0Aimport java.util.HashSet;%0Aimport java.util.List;%0Aimport java.util.Set;%0A%0A
 /**%0A * h
@@ -260,35 +260,1346 @@
     
-// TODO%0A        return null
+List%3CInteger%3E radiants = new ArrayList%3C%3E();%0A        List%3CInteger%3E dires = new ArrayList%3C%3E();%0A        char%5B%5D chars = senate.toCharArray();%0A        for (int i = 0; i %3C chars.length; i++) %7B%0A            if (chars%5Bi%5D == 'R') %7B%0A                radiants.add(i);%0A            %7D else %7B%0A                dires.add(i);%0A            %7D%0A        %7D%0A        int radiantIdx = 0;%0A        int direIdx = 0;%0A        Set%3CInteger%3E bannedRadiants = new HashSet%3C%3E();%0A        Set%3CInteger%3E bannedDires = new HashSet%3C%3E();%0A        while (bannedRadiants.size() %3C= radiants.size() %7C%7C bannedDires.size() %3C= dires.size()) %7B%0A            for (int i = 0; i %3C chars.length; i++) %7B%0A                if (bannedRadiants.size() == radiants.size()) %7B%0A                    return %22Dire%22;%0A                %7D%0A                if (bannedDires.size() == dires.size()) %7B%0A                    return %22Radiant%22;%0A                %7D%0A                if (chars%5Bi%5D == 'R') %7B%0A                    if (bannedRadiants.contains(i)) %7B%0A                        continue;%0A                    %7D%0A                    bannedDires.add(dires.get(direIdx++));%0A                %7D else %7B%0A                    if (bannedDires.contains(i)) %7B%0A                        continue;%0A                    %7D%0A                    bannedRadiants.add(radiants.get(radiantIdx++));%0A                %7D%0A            %7D%0A        %7D%0A        return %22%22
 ;%0A  
@@ -1688,24 +1688,26 @@
 oblem649();%0A
+//
         Syst
@@ -1757,32 +1757,34 @@
 %22)); // Radiant%0A
+//
         System.o
@@ -1836,16 +1836,18 @@
 // Dire%0A
+//
         
@@ -1907,24 +1907,26 @@
  // Radiant%0A
+//
         Syst
@@ -1986,16 +1986,408 @@
 Radiant%0A
+//        System.out.println(prob.predictPartyVictory(%22R%22)); // Radiant%0A//        System.out.println(prob.predictPartyVictory(%22D%22)); // Dire%0A//        System.out.println(prob.predictPartyVictory(%22DDRRR%22)); // Dire%0A//        System.out.println(prob.predictPartyVictory(%22RDDRDDDRRRDDRDRDRDDDDRRDR%22)); // Dire%0A        System.out.println(prob.predictPartyVictory(%22DRRDRDRDRDDRDRDR%22)); // Radiant%0A
     %7D%0A%7D%0A

Update problem 649