Easy Java Solution


  • 0
    K

    class Solution {
    public:
    bool judgeCircle(string moves) {
    int lr=0,ud=0;
    for(int i = 0;i < moves.length();i++){
    if(moves[i]=='L')
    lr++;
    else if(moves[i]=='R')
    lr--;
    else if(moves[i]=='U')
    ud++;
    else
    ud--;
    }
    if(lr==0 && ud==0)
    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.