Last active
February 9, 2018 02:11
-
-
Save jackliusr/e93d986d998c76297d6b to your computer and use it in GitHub Desktop.
Hackerrank Game Of Thrones - I, Terminated due to timeout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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