class Solution:
def judgeCircle(self, moves):
"""
:type moves: str
:rtype: bool
"""
U = 0
L = 0
for c in moves:
if c == 'U':
U += 1
elif c == 'D':
U -= 1
elif c == 'L':
L += 1
else:
L -= 1
if U == 0 and L == 0 :
return True
else:
return False
字符串处理
string