Solution in c++


  • 0
    T

    '''
    class Solution {
    public:
    bool judgeCircle(string moves) {
    int U, D, L, R;
    U = D = L = R = 0;

        for(auto move: moves) {
            switch(move) {
                case 'U': U++; break;
                case 'D': D++; break;
                case 'L': L++; break;
                case 'R': R++; break;
                default: return false;
            }
        }
        return ((U == D) && (L == R));
    }
    

    };
    '''


Log in to reply
 

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