LeetCode657.判断路线成圈
class Solution:
def judgeCircle(self, moves):
"""
:type moves: str
:rtype: bool
"""
count_R = 0
count_U = 0
for act in moves :
if act == 'R':
count_R = count_R + 1
elif act == 'L' :
count_R = count_R - 1
elif act == 'U' :
count_U = count_U + 1
elif act == 'D' :
count_U = count_U - 1
else :
pass
if count_U == 0 and count_R == 0 :
return True
else :
return False