java not clean code


  • 1
        public boolean judgeCircle(String moves) {
            int countV = 0, countH = 0;
            for (int i = 0; i < moves.length(); i++) {
                char c = moves.charAt(i);
                if (c == 'U') countV++;
                else if (c == 'D') countV--;
                else if (c == 'L') countH++;
                else countH--;
            }
            return countV == 0 && countH == 0;
        }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.