码迷,mamicode.com
首页 > 编程语言 > 详细

leetcode657 C++ 16ms

时间:2018-07-26 13:18:09      阅读:138      评论:0      收藏:0      [点我收藏+]

标签:public   tco   move   ring   turn   else   string   --   return   

class Solution {
public:
    bool judgeCircle(string moves) {
        int x = 0;
        int y = 0;
        for(auto c:moves){
            if(c==‘U‘){
                y++;
            }
            else if(c==‘D‘){
                y--;
            }
            else if(c==‘R‘){
                x++;
            }
            else if (c==‘L‘){
                x--;
            }
        }
        return (x==0 && y==0);
    }
};

leetcode657 C++ 16ms

标签:public   tco   move   ring   turn   else   string   --   return   

原文地址:https://www.cnblogs.com/theodoric008/p/9370942.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!