https://programmers.co.kr/learn/courses/30/lessons/12981
def solution(n, words):
current_word = [words[0]]
pre_word = words[0]
for i in range(1,len(words)):
#๋๋ง์๊ธฐ ๊ท์น์๋ฐ
if pre_word[-1] != words[i][0]:
return [(i % n)+1, (i//n)+1]
#์ด๋ฏธ ๋ฑ์ฅํ ๋จ์ด
elif words[i] in current_word:
return [(i % n)+1, (i//n)+1]
else:
current_word.append(words[i])
pre_word = words[i]
return [0,0]
'Algorithm > ํ๋ก๊ทธ๋๋จธ์ค' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[ํ๋ก๊ทธ๋๋จธ์ค] ๋ฉ์ฉกํ ์ฌ๊ฐํ - Python (1) | 2021.06.02 |
---|---|
[ํ๋ก๊ทธ๋๋จธ์ค] ํํ - Python (0) | 2021.05.18 |
[ํ๋ก๊ทธ๋๋จธ์ค] ์ฒด์ก๋ณต - Python (0) | 2021.05.18 |
[ํ๋ก๊ทธ๋๋จธ์ค] ๋ฉ๋ด๋ฆฌ๋ด์ผ - Python (0) | 2021.05.18 |
[ํ๋ก๊ทธ๋๋จธ์ค] ํฌ์ผ๋ชฌ - Python (0) | 2021.05.18 |