Judge Route Circle

2017/12/2 posted in  leetcode

class Solution {
public:
    bool judgeCircle(string moves) {
        int UD = 0 ,LR = 0;
        for(char a:moves){
            if (a=='U') {
                UD++;
            }else if (a=='D'){
                UD--;
            }else if (a=='L'){
                LR++;
            }else if (a=='R'){
                LR--;
            }
        }
        return (UD==0&&LR==0) ? 1:0;
    }
};