1 static int wing=[]() 2 { 3 std::ios::sync_with_stdio(false); 4 cin.tie(NULL); 5 return 0; 6 }(); 7 8 class Solution 9 { 10 public: 11 bool judgeCircle(string moves) 12 { 13 int count1=0,count2=0; 14 for(char c:moves) 15 { 16 if(c=='U') 17 count1++; 18 else if(c=='D') 19 count1--; 20 else if(c=='L') 21 count2++; 22 else 23 count2--; 24 } 25 return count1==0&&count2==0; 26 } 27 };
很简单