解题思路:
给定的字符串中字符L和字符R,字符U和字符D的个数分别相等,则可以在 (0, 0) 处结束。
class Solution {public boolean judgeCircle(String moves) {int len=moves.length();int left=0,right=0,up=0,down=0;for(int i=0;i<len;++i){if(moves.charAt(i)=='U'){up++;}else if(moves.charAt(i)=='D'){down++;}else if(moves.charAt(i)=='L'){left++;}else{right++;}}if(left==right&&up==down){return true;}return false;}
}