반응형
250x250
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 자바
- 백준
- 백준 그래프 이론 파이썬
- 코딩
- 정보처리기사 실기 시험
- 2022년 정보처리기사 실기 가답안
- BFS
- 백준 토마토 파이썬
- 2022년 정보처리기사 실기 1회 가답안
- 알고리즘
- 프로그래밍
- 파이썬
- 백준 그래프 탐색 파이썬
- 백준 N-Queens
- 코드
- it
- 정보처리기사 실기
- python
- 프로그래머스
- 그리디
- 백준 백트랙킹 파이썬
- dfs
- 토마토
- 코딩테스트
- 정보처리기사
- 프로그래머스 파이썬
- 자료구조
- BOJ
- 백준 백트랙킹
- 2022년 정보처리기사 실기
Archives
- Today
- Total
코딩,안되면 될때까지
타겟넘버 본문
728x90
반응형
<문제>
https://programmers.co.kr/learn/courses/30/lessons/43165
<코드>
-파이썬-
from collections import deque
def solution(numbers, target):
answer = 0
q = deque()
q.append([numbers[0],0])
q.append([-1*numbers[0],0])
n = len(numbers)
while q:
temp,index = q.popleft()
index+=1
if index<n:
q.append([temp+numbers[index],index])
q.append([temp-numbers[index],index])
else:
if temp == target:
answer+=1
return answer
728x90
반응형
'프로그래머스 > 프로그래머스-파이썬' 카테고리의 다른 글
[프로그래머스]-괄호변환 (4) | 2022.03.12 |
---|---|
무지의 먹방 라이브 (0) | 2022.02.26 |
조이스틱 (0) | 2022.02.26 |
2.오픈채팅방 (0) | 2022.01.13 |
1.문자열 압축 (0) | 2022.01.12 |
Comments