파이썬 코딩테스트/프로그래머스

프로그래머스 / 영어 끝말잇기 / 파이썬

S.T.Lee 2022. 10. 6. 23:27
def solution(n, words):
    list_ = [words[0]]
    for i in range(1, len(words)):
        if words[i-1][-1] != words[i][0]:
            return [i%n +1, i//n+1]
        if words[i] in list_:
            return [i%n +1, i//n+1]
        list_.append(words[i])
    return [0,0]