Skip to content

Baekjoon 1141

1. Problem

문제 확인하기

2. Solution

import sys

n = int(sys.stdin.readline())
words = [(sys.stdin.readline()).rstrip() for _ in range(n)]
res = 0
words.sort(key = len)

for i in range(n):
    flag = False
    for j in range(i + 1, n):
        if words[i] == words[j][0:len(words[i])]:
            flag = True
            break
    
    if not flag:
        res += 1

print(res)