Sherlock and the Valid String

  • + 0 comments

    my c# code like this:

       public static string isValid(string s)
        {
            var temp = s.GroupBy(x=> x).GroupBy(x=> x.Count());
            return temp.Where(x=> x.Count() == 1).Count() == 1 ? "YES" : "NO";
        }
    

    but it failed for test cases 3,5,14