Skip to content
Open
Changes from all commits
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
33 changes: 33 additions & 0 deletions 16주차/(P)17677/17677_py_jy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import math
a = 65536

def check(strr):
strr = strr.lower()
listt = []
for i in range(len(strr) - 1):
if strr[i:i + 2].isalpha():
listt.append(strr[i:i + 2])
return listt

def solution(str1, str2):
s1 = check(str1)
s2 = check(str2)
if s1 == [] and s2 == []:
return a

s1_cp = s1.copy()
s2_cp = s2.copy()

# 교집합
join = []
for i in s1:
if i in s2_cp:
join.append(i)
s1_cp.remove(i)
s2_cp.remove(i)
Comment on lines +24 to +27
Copy link
Collaborator

Choose a reason for hiding this comment

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

리스트에서 in, remove는 O(N)으로 느립니다. set, dict, Counter등을 이용해서 최적화할 수 있습니다.

# 합집합
union = join + s1_cp + s2_cp
answer = math.floor((len(join) / len(union)) * a)
return answer

#print(solution("FRANCE", "french"))