657. Judge Route Circle

思路:略,很简单

java版本

class Solution {
    public boolean judgeCircle(String moves) {
        
        int x = 0;
        int y = 0;
        char[] movestmp = moves.toCharArray();
        for(char key : movestmp)
        {
            switch (key) {
            case 'U':
            {
                y += 1;
                break;
            }
            case 'D':
            {
                y--;
                break;
            }
            case 'L':
            {
                x--;
                break;
            }
            case 'R':
            {
                x++;
                break;
            }
                
            default:
                break;
            }
        }
        return x == 0 && y == 0;

    }
}

----------------

 

posted @ 2017-12-06 10:56  深海芷兰  阅读(123)  评论(0)    收藏  举报