| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
Tags
- 스탭퍼
- leetcode
- 파비최
- 괜찮음
- 영어원서읽기
- Daily Challenge
- 쓰릴오브파이트
- Problem Solving
- 3줄정리
- 화상영어
- 영어공부
- 읽기
- realclass
- Writing
- 사이드
- 만화도
- English
- 월간
- 프로젝트
- 미드시청
- FIT XR
- 매일
- 10분
- 운동
- 링피트
- 리얼 클래스
- 개발자
- 잡생각
- 뭐든
- 30분
Archives
- Today
- Total
파비의 매일매일 공부기록
Today's Challenge 본문
https://leetcode.com/problems/find-players-with-zero-or-one-losses/
Find Players With Zero or One Losses - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
map을 이용해서 풀 수 있는 간단한 문제!
class Solution:
def findWinners(self, matches: List[List[int]]) -> List[List[int]]:
res = {}
for match in matches:
w, l = match[0], match[1]
if not res.get(l):
res[l] = 1
if not res.get(w):
res[w] = 0
continue
if not res.get(w):
res[w] = 0
res[l] += 1
sorted_res = sorted(res.items())
zero, one = [], []
for r in sorted_res:
if r[1] == 0:
zero.append(r[0])
if r[1] == 1:
one.append(r[0])
return [zero, one]반응형
'Problem Solving > LeetCode' 카테고리의 다른 글
| Today's Challenge (0) | 2022.11.30 |
|---|---|
| Today's Challenge (0) | 2022.11.29 |
| Today's Challenge (0) | 2022.11.27 |
| Today's Challenge (0) | 2022.11.26 |
| Today's Challenge (0) | 2022.11.25 |
Comments