殇感故事

关注

Leetcode_Python 657 机器人能否返回原点

殇感故事

关注

阅读 48

2023-04-07


Leetcode_Python  657 机器人能否返回原点_hash

解题思路

统计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


相关推荐

春意暖洋洋

leetcode-657-机器人能否返回原点 题解

春意暖洋洋 32 0 0

左手梦圆

LeetCode 657. 机器人能否返回原点 | 算法-从菜鸟开始

左手梦圆 122 0 0

Go_Viola

C++ 657. 机器人能否返回原点 简单模拟

Go_Viola 10 0 0

像小强一样活着

【坚持每日一题5.25】657. 机器人能否返回原点

像小强一样活着 64 0 0

左小米z

Peoeasy机器人:原点无法重置问题

左小米z 7 0 0

树下的老石头

python 飞书 机器人

树下的老石头 16 0 0

yundejia

LeetCode题解(0874):模拟行走的机器人(Python)

yundejia 101 0 0

幸福的无所谓

LeetCode题解(1041):困于环中的机器人(Python)

幸福的无所谓 57 0 0

践行数据分析

量化机器人能否提高市场预测精度?

践行数据分析 30 0 0

醉倾城1

rpa 数字机器人 python

醉倾城1 42 0 0

精彩评论(0)

0 0 举报