티스토리 뷰
1. 문제

2. 소스코드 ( Python3 )
|
def search(priorities, next, cnt): index = next for i in range(cnt-1): index += 1 if index == cnt: index = 0 if priorities[next] < priorities[index]: next = index
return next
def solution(priorities, location): answer = 0 # 변수 next = 0 # 다음에 프린트할 문서 index cnt = len(priorities) # 전체 문서 개수
while True: # next 찾기 next = search(priorities, next, cnt)
# 프린트 하기 answer += 1 if next == location: #print("최종 = ", answer) return answer priorities[next] = 0 |
3. 고찰
1) 리스트 길이 n만큼 0으로 초기화
list = [0 for i in range(n)]
리스트를 mxn행렬의 0으로 초기화
matrix = [[0 for col in range(n)] for row in range(m)]
'프로그래밍 > Python' 카테고리의 다른 글
| 프로그래머스_기능개발 (0) | 2020.10.04 |
|---|---|
| 프로그래머스_더 맵게 (0) | 2020.10.03 |
| 프로그래머스_다리를 건너는 트럭 (0) | 2020.09.28 |
| 프로그래머스_주식가격 (0) | 2020.09.28 |
| 프로그래머스_코딩테스트연습_124나라의 숫자 (0) | 2020.09.24 |
- Total
- Today
- Yesterday
- roslaunch
- 포트인식문제
- 리눅스
- VirtualBox
- subscriber
- 백준알고리즘
- 윈도우
- Python
- 윈도우 복구
- vue/cli
- Publisher
- filesystem
- VMware
- HC-SR04
- 8자주행
- Ubuntu16.04
- 초음파센서
- Mount
- sensehat
- C++
- Ubuntu20.04
- set backspace
- 원격 통신
- umount
- 우분투
- python3
- 프로그래머스
- 코드리뷰
- ROS
- 아두이노 IDE
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
