Add to List 657. Judge Route Circle

来源:互联网 发布:重庆专业u盘数据恢复 编辑:程序博客网 时间:2024/06/11 21:43
class Solution {public:    bool judgeCircle(string moves) {        std::map<char,int> count;        for(int i = 0;i<moves.size();i++){            if(count.find(moves[i]) == count.end())                count[moves[i]] = 1;            else                count[moves[i]] ++;        }        if ((count['L'] == count['R'])&& (count['U'] == count['D']))            return true;        else            return false;    }};