일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 만화도
- 개발자
- 파비최
- 매일
- 괜찮음
- 잡생각
- 링피트
- 미드시청
- 화상영어
- 읽기
- 30분
- Daily Challenge
- realclass
- 프로젝트
- FIT XR
- 영어원서읽기
- 10분
- 쓰릴오브파이트
- 운동
- leetcode
- 영어공부
- 월간
- 사이드
- 스탭퍼
- Writing
- English
- 리얼 클래스
- Problem Solving
- 뭐든
- 3줄정리
Archives
- Today
- Total
파비의 매일매일 공부기록
2023.11.09 Today's Challenge 본문
Eliminate Maximum Number of Monsters - LeetCode
Can you solve this real interview question? Eliminate Maximum Number of Monsters - You are playing a video game where you are defending your city from a group of n monsters. You are given a 0-indexed integer array dist of size n, where dist[i] is the initi
leetcode.com
순차적으로 시뮬레이션을 해보았으나 계속 실패 ㅠ
솔루션 보니, 평균값을 구해서 답을 찾는 방법이 있었음...
class Solution:
def eliminateMaximum(self, dist: List[int], speed: List[int]) -> int:
arv = sorted([dist[i]/speed[i] for i in range(len(dist))])
ans = 0
for i in range(len(arv)):
if arv[i] <= i:
break
ans += 1
return ans
반응형
'Problem Solving > LeetCode' 카테고리의 다른 글
2023.11.11 Today's Challenge (1) | 2023.11.11 |
---|---|
2023.11.10 Today's Challenge (0) | 2023.11.10 |
2023.11.08 Today's Challenge (0) | 2023.11.08 |
2023.11.07 Today's Challenge (0) | 2023.11.07 |
2023.11.06 Today's Challenge (1) | 2023.11.06 |
Comments