| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 | 31 |
Tags
- lv4
- 조합
- 코테
- coding
- counter
- 코딩테스트
- LeetCode
- 파이썬
- Level2
- Queue
- cte
- level4
- mysql
- time complexity
- AARRR
- Stack
- tableau
- Growth hacking
- collections
- sql
- coding test
- 완전탐색
- itertools
- programmers
- lambda
- python
- join
- 프로그래머스
- 코딩
- import re
Archives
- Today
- Total
ror_coding
[Programmers] 연속 부분 수열 합의 개수 - 131701 본문
728x90
원형 수열 리스트를 *2 해서 사용하기.
Question
원형 수열의 모든 원소 elements가 순서대로 주어질 때, 원형 수열의 연속 부분 수열 합으로 만들 수 있는 수의 개수를 return 하도록 solution 함수를 완성해주세요.
Code
def solution(elements):
answer = []
circle = elements*2
for i,num in enumerate(elements):
answer.append(num)
for num2 in circle[i+1:i+len(elements)]:
num += num2
answer.append(num)
return len(set(answer))

now me
On my github
728x90
'Coding Test > Python' 카테고리의 다른 글
| [Programmers] H-Index - 42747 (0) | 2024.12.02 |
|---|---|
| [Programmers] n^2 배열 자르기 - 87390 (0) | 2024.11.01 |
| [Programmers] 예상 대진표 - 12985 (0) | 2024.10.31 |
| [Programmers] 멀리 뛰기 - 12914 (1) | 2024.10.31 |
| [Programmers] 점프와 순간 이동 - 12980 (0) | 2024.10.28 |