20.12.11 leetcode649
题目链接:https://leetcode-cn.com/problems/dota2-senate/
题意&&分析:说是中等题,结果简单的要命,不提了。
class Solution { public: string predictPartyVictory(string senate) { int num1=0,num2=0,diff1=0,diff2=0; for(auto& v: senate){ if(v=='R')num1++; if(v=='D')num2++; } while(1){ for(auto& v : senate){ if(v=='N')continue; else if(v=='R'){ if(diff1){ diff1--; num1--; v='N'; continue; } diff2++; } else if(v=='D'){ if(diff2){ diff2--; num2--; v='N'; continue; } diff1++; } if(num1==0)return "Dire"; if(num2==0)return "Radiant"; } } } };