ji-0630 / CodingTest

코딩테스트 연습 기록
0 stars 0 forks source link

외계어 사전 #178

Closed ji-0630 closed 1 year ago

ji-0630 commented 1 year ago

문제 설명

image image

ji-0630 commented 1 year ago

나의 풀이

def solution(spell, dic):
    ans= 0
    for i in dic:
        for j in spell:
            if j in i:
                ans += 1
        if ans == len(spell):
            return 1
        else:
            ans = 0
    return 2
ji-0630 commented 1 year ago

다른 사람의 풀이

def solution(spell, dic):
    for d in dic:
        if sorted(d) == sorted(spell):
            return 1
    return 2