Sherlock and the Valid String

  • + 0 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"; }