← Back to List

3986번: 좋은 단어 ↗

Solutions

Python 3
253 B | 253 chars
def is_good_word(word):
  stk = []

  for ch in word:
    if stk and stk[-1] == ch:
      stk.pop()
    else:
      stk.append(ch)

  return not stk

words = [input() for _ in range(int(input()))]
print(sum([1 for word in words if is_good_word(word)]))