본문 바로가기
파이썬 코딩테스트/해커랭크

HackerRank / Games of Thrones - 1 / Python

by S.T.Lee 2022. 1. 2.

https://www.hackerrank.com/challenges/game-of-thrones/problem?isFullScreen=true

s를 재정렬해서 좌우대칭이 되면 된다.

홀수번 등장하는 인자가 2번 이상 나오면 불가능하다.

def gameOfThrones(s):
    # Write your code here
    limit = 0
    for ss in set(s):
        if s.count(ss) % 2 == 1:
            limit += 1
        
    if limit >= 2:
        return "NO"
    else:
        return "YES"