You are viewing a single comment's thread. Return to all comments →
def isValid(s: String): String = s.groupBy(identity) .values.map(_.size) .groupBy(identity) match { case x if x.size<=1 => "YES" case x if x.size==2 => (x.head._2.size, x.last._2.size, x.head._1 , x.last._1) match { case (1,_,1,_) | (_,1,_,1) => "YES" case (1,_,c,d) if c==d+1 => "YES" case (_,1,c,d) if c+1==d => "YES" case_ => "NO" } case _ => "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 →