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"
'파이썬 코딩테스트 > 해커랭크' 카테고리의 다른 글
HackerRank / Append and Delete / Python (0) | 2022.01.05 |
---|---|
HackerRank / Strange Counter / Python (0) | 2022.01.03 |
HackerRank / Two Strings / Python (0) | 2022.01.02 |
HackerRank / Anagram / Python (0) | 2021.12.31 |
HackerRank / Making Anagrams / Python (0) | 2021.12.31 |