๋ฌธ์
https://school.programmers.co.kr/learn/courses/30/lessons/131701
ํ์ด
# ํ๋ก๊ทธ๋๋จธ์ค 2๋จ๊ณ - ์ฐ์ ๋ถ๋ถ ์์ด ํฉ์ ๊ฐ์
def solution(elements):
result = set()
elements_length = len(elements)
elements = elements * 2
for i in range(elements_length):
for j in range(elements_length):
result.add(sum(elements[j:j+i+1]))
return len(result)
print(solution([7,9,1,1,4]))
๋ฐฐ์ด์ ํฌ๊ธฐ๋ฅผ ๋๋ฐฐ ๋๋ ค์ ์ธ๋ฑ์ค ์ด๊ณผ๋ฅผ ๋ง์์ฃผ๋ ๋ฐฉ์์ ์ฌ์ฉํ๋ค.
'๐๏ธ Algorithm > โฌ ํ๋ก๊ทธ๋๋จธ์ค' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
โฌ [Programmers] [Python] [Level2] ํผ๋ก๋ (0) | 2023.04.06 |
---|---|
โฌ [Programmers] [Python] [Level3] ์ต๊ณ ์ ์งํฉ (0) | 2023.04.06 |
โฌ [Programmers] [Python] Level2_์์ฅ (0) | 2023.04.06 |
โฌ [Programmers] [Python] Level2_๊ทค ๊ณ ๋ฅด๊ธฐ (0) | 2023.04.06 |
โฌ [Programmers] [BFS/DFS] [Python] Level2_H-Index (0) | 2023.02.14 |