leetcode 657 Judge Route Circle

来源:互联网 发布:网络视频广告数据分析 编辑:程序博客网 时间:2024/06/09 14:57
class Solution {    public boolean judgeCircle(String moves) {        int x=0,y=0;        for(int i=0;i<moves.length();i++){            if(moves.charAt(i)=='U') x++;            else if(moves.charAt(i)=='D') x--;            else if(moves.charAt(i)=='L') y++;            else if(moves.charAt(i)=='R') y--;        }        return x==0&y==0;    }}

原创粉丝点击