코테 공부

프로그래머스 Lv.2 영어 끝말잇기

dnjswngo 2024. 11. 9. 17:32
def solution(n, words):
    an1=an2=0
    arr=[]
    for i in range(len(words)-1):
        arr.append(words[i])
        if words[i+1] in arr or words[i][-1]!=words[i+1][0]:
            an1=(i+1)%n +1
            an2=(i+1)//n+1
            break

    answer=[an1, an2]
    return answer

 

호호 오랜만에 1트에 성공했지