解题思路
统计R(右),L(左),U(上)和 D(下)的步数,R与L相同,U和D相同即可
代码
class Solution:
def judgeCircle(self, moves: str) -> bool:
hash = {i:0 for i in {"U","D","L","R"}}
for i in moves:
hash["%s"%i] += 1
if hash["U"]==hash["D"] and hash["L"]==hash["R"]:
return True
else:
return False