1class Solution {2public:3bool judgeCircle(string moves) {4int n = moves.size();5int a = 0;6int b = 0;7int c = 0;8int d = 0;9for (int i = 0; i < n; i++) {10if (moves[i] == 'R') {11a = a + 1;12}13if (moves[i] == 'L') {14b = b + 1;15}16if (moves[i] == 'U') {17c = c + 1;18}19if (moves[i] == 'D') {20d = d + 1;21}22}23/*if(a==b && c==0 && d==0)24{25return true;26}27if(c==d && a==0 && b==0)28{29return true;30}*/31if (a == b && b == c && c == d) {32return true;33}34if (a == b && c == d) {35return true;36}37return false;38}39};