C# solution beats 90%


  • 0
    D
    public class Solution {
        public bool DetectCapitalUse(string word) {
            int count = 0;
            if(word!=string.Empty)
            {
                foreach(char c in word)
                {
                    if(char.IsUpper(c))
                    {
                        count++;
                    }
                }
            }
            if(count == 0 || count == word.Length)
            return true;
            else if(count == 1 && char.IsUpper(word[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.