๊ด€๋ฆฌ ๋ฉ”๋‰ด

๐Ÿฆ• ๊ณต๋ฃก์ด ๋˜์ž!

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] Python ์™„์ฃผํ•˜์ง€ ๋ชปํ•œ ์„ ์ˆ˜ ๋ณธ๋ฌธ

Development/CodingTest

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] Python ์™„์ฃผํ•˜์ง€ ๋ชปํ•œ ์„ ์ˆ˜

Kirok Kim 2022. 1. 13. 23:25

 

def solution(participant, completion):
    p=sorted(participant)
    c=sorted(completion)
    
    for i in range(len(c)):
        if p[i] != c[i]:
            return p[i]
    
      
    return p[len(p)-1]
hash๋ฅผ ์ด์šฉํ•œ ํ’€์ด
def solution(participant, completion):
    answer = ''
    temp = 0
    dic = {}
    for part in participant:
        dic[hash(part)] = part
        temp += int(hash(part))
    for com in completion:
        temp -= hash(com)
    answer = dic[temp]

    return answer
  • ...ํ™˜์ƒ์ ์ด๋‹ค.....
๋ฐ˜์‘ํ˜•
Comments