class Solution:
def judgeCircle(self, moves):
"""
:type moves: str
:rtype: bool
"""
a=0
b=0
c=0
d=0
for i in moves:
if i=='U':
a+=1
elif i=='D':
b+=1
elif i=='L':
c+=1
elif i=='R':
d+=1
if a-b==0 and c-d==0:
return True
return False#leetcode 657
最新推荐文章于 2024-02-13 20:21:38 发布
本文介绍了一个简单的Python函数,用于判断给定的移动指令是否能使一个虚拟角色回到起点。该函数通过计算向上、向下、向左和向右移动的次数来确定最终位置是否与起始位置相同。
311

被折叠的 条评论
为什么被折叠?



