일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- Decorator
- data science
- Python
- Class
- 프로그래머스
- Regular Expression
- 밴픽
- 109. Convert Sorted List to Binary Search Tree
- t1
- 30. Substring with Concatenation of All Words
- Convert Sorted List to Binary Search Tree
- concurrency
- 시바견
- 파이썬
- 715. Range Module
- shiba
- attribute
- 운영체제
- 315. Count of Smaller Numbers After Self
- iterator
- Python Implementation
- 컴퓨터의 구조
- kaggle
- Protocol
- Generator
- Substring with Concatenation of All Words
- LeetCode
- Python Code
- 43. Multiply Strings
- DWG
Archives
- Today
- Total
Scribbling
프로그래머스: 순위 본문
Floyd-Warshall 알고리즘을 사용한다.
https://focalpoint.tistory.com/6
def solution(n, results):
graph = [[0] * (n+1) for _ in range(n+1)]
for result in results:
w, l = result
graph[w][l] = 1
graph[l][w] = -1
for k in range(1, n+1):
for i in range(1, n+1):
for j in range(1, n+1):
if graph[i][j] == 0:
if graph[i][k] == graph[k][j]:
graph[i][j] = graph[i][k]
answer = 0
for i in range(1, n+1):
c = 0
for j in range(1, n+1):
if graph[i][j] != 0:
c += 1
if c == n - 1:
answer += 1
return answer
'Computer Science > Coding Test' 카테고리의 다른 글
프로그래머스: 방의 개수 (0) | 2021.11.08 |
---|---|
LeetCode: 127. Word Ladder (0) | 2021.11.07 |
프로그래머스: 가장 먼 노드 (0) | 2021.11.05 |
LeetCode: 124. Binary Tree Maximum Path Sum (0) | 2021.11.04 |
LeetCode: 188. Best Time to Buy and Sell Stock IV (0) | 2021.11.04 |