1104. Judge Route Circle
class Solution {
public:
/**
* @param moves: a sequence of its moves
* @return: if this robot makes a circle
*/
bool judgeCircle(string &moves) {
// Write your code here
unordered_map<char, int> map;
for(int i = 0; i < moves.size(); i++){
map[moves[i]]++;
}
return map['L'] == map['R'] && map['U'] == map['D'];
}
};
Comments
Post a Comment