(c++) My solution with std::map


  • 0
    M
    class Solution {
    public:
        bool judgeCircle(string s) {
            map<char,int> M;
            for(int i=0;i<s.length();i++)
            {
                M[s[i]]++;
            }
            if ((M['U']==M['D']) && (M['L']==M['R']))
            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.