solution in csharp


  • 0
    C
    public class Solution {
        public bool JudgeCircle(string moves) {
                int countR = 0;
                int countL = 0;
                int countU = 0;
                int countD = 0;
                foreach(var ch in moves)
                {
                    switch (ch)
                    {
                        case 'R':
                            countR++;
                            break;
                        case 'L':
                            countL++;
                            break;
                        case 'U':
                            countU++;
                            break;
                        case 'D':
                            countD++;
                            break;
                    }                  
                }
                return (countR == countL && countD == countU) ? true : false;
        }
    }
    

Log in to reply
 

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