1 Star 0 Fork 0

ZENGWatermelon/LeetCode

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
649.dota-2-参议院.py 1004 Bytes
一键复制 编辑 原始数据 按行查看 历史
sunzhaoc 提交于 2020-11-25 21:32 . master
'''
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
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/watermelonTT/LeetCode.git
git@gitee.com:watermelonTT/LeetCode.git
watermelonTT
LeetCode
LeetCode
master

搜索帮助