- 구현
- 문자열
n = int(input())
lst = [0] * 26
for _ in range(n):
a, b = map(str, input().split())
for i in a:
lst[ord(i)-97] += 1
for j in b:
lst[ord(j)-97] -= 1
if max(lst) == 0 and min(lst) == 0: # 다 0이 아닌경우에 가능
print('Possible')
else:
print('Impossible')
lst = [0] * 26 # 초기화
- 아스키코드
ord(문자) = 숫자 ; 문자를 숫자로 바꿔주는 함수
ord('a') = 97 이기 때문에
ord('a')-97로 0으로 만들어서 lst와 index를 맞춰준다.