代码拉取完成,页面将自动刷新
'''
Description:
Version: 1.0
Author: Vicro
Date: 2020-11-24 22:14:25
LastEditTime: 2020-11-25 19:32:06
FilePath: \Leetcode\649.dota-2-参议院.py
'''
#
# @lc app=leetcode.cn id=649 lang=python3
#
# [649] Dota2 参议院
#
# @lc code=start
class Solution:
def predictPartyVictory(self, senate):
senate = list(senate)
R, D = True, True
person = 0
while R and D:
R, D = False, False
for i in range(len(senate)):
if senate[i] == "R":
R = True
if person < 0:
senate[i] = "0"
person += 1
elif senate[i] == "D":
D = True
if person > 0:
senate[i] = "0"
person -= 1
if person > 0:
return "Radiant"
else:
return "Dire"
sol = Solution()
A = sol.predictPartyVictory("DDRRR")
print(A)
# @lc code=end
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。