robot solution


  • 0
    K

    class Solution {
    public:
    bool judgeCircle(string moves) {
    int L=0,R=0,U=0,D=0;
    for(int i = 0;i<moves.size();i++){
    if(moves[i]=='L') L++;
    if(moves[i]=='R') R++;
    if(moves[i]=='U') U++;
    if(moves[i]=='D') D++;
    }
    if(L==R&&U==D) return true;
    else return false;
    }
    };


Log in to reply
 

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