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.
Sherlock and the Valid String
Sherlock and the Valid String
Sort by
recency
|
2027 Discussions
|
Please Login in order to post a comment
This might be one of the most poorly worded questions
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"; }
The string is valid if Sherlock can remove 1 character at index = 1... Later in the problem it says you can remove two to get a valid string.....