Skip to content

Instantly share code, notes, and snippets.

@jackliusr
Last active February 9, 2018 02:11
Show Gist options
  • Save jackliusr/e93d986d998c76297d6b to your computer and use it in GitHub Desktop.
Save jackliusr/e93d986d998c76297d6b to your computer and use it in GitHub Desktop.
Hackerrank Game Of Thrones - I, Terminated due to timeout
object Solution {
def main(args: Array[String]) {
val line = io.Source.stdin.getLines().filter(_.length > 0).take(1).toList(0)
def existsPalindrome(str:String):Boolean = {
val freqs = str.groupBy( k => k)
freqs.count( { case (k,v ) => v.length %2 == 1 } ) <= 1
}
println (if(existsPalindrome(line)) "YES" else "NO")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment