657. Robot Return to Origin

class Solution:
    def judgeCircle(self, moves: str) -> bool:
        u,d,l,r = 0,0,0,0
        for move in moves:
            if move is ‘U‘:
                u += 1
            elif move is ‘D‘:
                d += 1
            elif move is ‘L‘:
                l += 1
            elif move is ‘R‘:
                r += 1
        if u!=d or l!=r:
            return False
        return True

  76ms,13.1M

原文地址:https://www.cnblogs.com/accumulationbystep/p/10448572.html

时间: 2024-11-08 17:37:26

657. Robot Return to Origin的相关文章

【leetcode】657. Robot Return to Origin

Algorithm [leetcode]657. Robot Return to Origin https://leetcode.com/problems/robot-return-to-origin/ 1)problem There is a robot starting at position (0, 0), the origin, on a 2D plane. Given a sequence of its moves, judge if this robot ends up at (0,

[Leetcode]657. Robot Return to Origin

Easy There is a robot starting at position (0, 0), the origin, on a 2D plane. Given a sequence of its moves, judge if this robot ends up at (0, 0) after it completes its moves. The move sequence is represented by a string, and the character moves[i]

(Easy) Robot Return to Origin LeetCode

Description here is a robot starting at position (0, 0), the origin, on a 2D plane. Given a sequence of its moves, judge if this robot ends up at (0, 0) after it completes its moves. The move sequence is represented by a string, and the character mov

【LeetCode】字符串 string(共112题)

p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica } [3]Longest Substring Without Repeating Characters [5]Longest Palindromic Substring [6]ZigZag Conversion [8]String to Integer (atoi) [10]Regular Expression Matching [12]Integer to Roman

【Leetcode周赛】从contest-41开始。(一般是10个contest写一篇文章)

Contest 41 ()(题号) Contest 42 ()(题号) Contest 43 ()(题号) Contest 44 (2018年12月6日,周四上午)(题号653-656) 链接:https://leetcode.com/contest/leetcode-weekly-contest-44 比赛情况记录:就做出来两题,第三题不难,然而就是在算坐标的时候卡住了.orz.结果:2/4,ranking:637/2272.第四题没看题,第三题搞得心情不好了orz. [653]Two Sum

hdu 5673 Robot 卡特兰数+逆元

Robot Time Limit: 12000/6000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Problem Description There is a robot on the origin point of an axis.Every second, the robot can move right one unit length or do nothing.If the robot is on the

hdu5673 Robot 卡特兰数+组合数学+线性筛逆元

Robot Time Limit: 12000/6000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 483    Accepted Submission(s): 244 Problem Description There is a robot on the origin point of an axis.Every second, the robot can move rig

s3c2440 移值u-boot-2016.03 第6篇 支持mtd yaffs 烧写

1, 解决启动时的错误 Warning - bad CRC, using default environment 搜索发现 在 /tools/env/fw_env.c 中 /* 放在NAND FLASH 中 大小 128K 开始地址 */ #define CONFIG_ENV_IS_IN_NAND #define CONFIG_SYS_ENV_SECT_SIZE (128 << 10) #define CONFIG_ENV_OFFSET (256<<10) #define CONF

用c/c++混合编程方式为ios/android实现一个自绘日期选择控件(一)

本文为原创,如有转载,请注明出处:http://www.cnblogs.com/jackybu 前言 章节: 1.需求描述以及c/c++实现日期和月历的基本操作 2.ios实现自绘日期选择控件 3.android实现自绘日期选择控件 目的: 通过一个相对复杂的自定义自绘控件来分享: 1.ios以及android自定义自绘控件的开发流程 2.objc与c/c++混合编程 3.android ndk的环境配置,android studio ndk的编译模式,swig在android ndk开发中的作