Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

05 우선순위큐 #2

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions 2607.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import sys
input = sys.stdin.readline

N = int(input())
result = 0

word = input()
alpa = [0]*26

for i in range(len(word)-1):
alpa[ord(word[i])-ord('A')] += 1

for _ in range(N-1):
ow = input()
oa = [0]*26
cnt = 0

for i in range(len(ow)-1):
oa[ord(ow[i])-ord('A')] += 1
Comment on lines +18 to +19
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

알파벳 개수를 따로 저장하여 해결해 주셨네요!👍👍


for i in range(26):
if alpa[i] != oa[i]:
cnt += abs(alpa[i] - oa[i])


if len(word) == len(ow):
if cnt == 0 or cnt == 2:
result +=1

else:
if cnt == 1 and abs(len(word) - len(ow)) == 1:
result += 1
Comment on lines +26 to +32
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

문제의 핵심을 정확히 파악하셨습니다! 조건 나누기가 아주 깔끔합니다.😮


print(result)