We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
var r = s
.GroupBy(s => s, (str, c) => new { letter = str, count = c.Count() })
.GroupBy(s => s.count, (c, e) => new { totalCount = c, counts = e.Count() }).ToList();
Sherlock and the Valid String
You are viewing a single comment's thread. Return to all comments →
failing test 7 and 13 ugh cant see it
var r = s .GroupBy(s => s, (str, c) => new { letter = str, count = c.Count() }) .GroupBy(s => s.count, (c, e) => new { totalCount = c, counts = e.Count() }).ToList();
if (r.Count == 1) { return "YES"; }
if (r.Count > 2) { return "NO"; }
if (r[1].totalCount - r[0].totalCount == 1 && r[1].counts == 1) { return "YES"; } else if (r[0].totalCount - r[1].totalCount == 1 && r[1].counts == 1) { return "YES"; }
else { return "NO"; }