Game of Thrones - I

  • + 0 comments

    Python 3 solution:

    def gameOfThrones(s):
        d = {}
        for i in s:
            d[i] = d.get(i, 0) + 1
        return('YES' if sum(i % 2 for i in d.values()) < 2 else 'NO')
    

    In a palindrome, only 1 character at most can appear an odd number of times.. If more than 1 character appears an odd number times, we return 'NO',