You are viewing a single comment's thread. Return to all comments →
C# - For some reason, case 14 isn't working for me, but it's too large to manually test,. and it isn't showing me my output.
var buckets = new Dictionary<char, int>(); var arr = s.ToCharArray(); foreach(var c in arr) { if(!buckets.ContainsKey(c)) { buckets.Add(c,1); } else { buckets[c] += 1; } } foreach(var c in buckets.Keys) { Console.WriteLine($"{c} {buckets[c]}"); // Clone buckets if(buckets[c] == 1) { Console.WriteLine(buckets[c]); var tempBuckets = buckets.Where(item => item.Key != c); tempBuckets = tempBuckets.OrderBy(item => item.Value); if(tempBuckets.Count() == 0 || tempBuckets.First().Value == tempBuckets.Last().Value) { return "YES"; } } else { buckets[c] -= 1; if(buckets.Values.Max() == buckets.Values.Min()) { return "YES"; } buckets[c] += 1; } } return "NO";
Seems like cookies are disabled on this browser, please enable them to open this website
Sherlock and the Valid String
You are viewing a single comment's thread. Return to all comments →
C# - For some reason, case 14 isn't working for me, but it's too large to manually test,. and it isn't showing me my output.