| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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
- Daily Challenge
- 읽기
- 미드시청
- 개발자
- 잡생각
- Problem Solving
- English
- 쓰릴오브파이트
- 매일
- 스탭퍼
- 10분
- 괜찮음
- 파비최
- 뭐든
- 운동
- 프로젝트
- 영어원서읽기
- realclass
- 30분
- 화상영어
- 3줄정리
- leetcode
- 영어공부
- 리얼 클래스
- 월간
- FIT XR
- Writing
- 사이드
- 링피트
- 만화도
Archives
- Today
- Total
파비의 매일매일 공부기록
Today's Challenge 본문
https://leetcode.com/problems/maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts/
Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts - 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
set을 써서 구현.
문제에 주어진 조건대로 풀면 됨. 10^9 + 7 mod 연산 때문에 좀 쫄긴했는데
사실 그냥 간격 나눠진 값들 중 h, w의 가장 큰 값만 가져와서 계산하면 되는 간단한 문제.
class Solution:
def maxArea(self, h: int, w: int, hc: List[int], vc: List[int]) -> int:
dh, dv = set(), set()
hc = sorted([0] + hc + [h])
vc = sorted([0] + vc + [w])
for i in range(1, len(hc)):
dh.add(hc[i] - hc[i-1])
for i in range(1, len(vc)):
dv.add(vc[i] - vc[i-1])
return (sorted(dh)[-1]*sorted(dv)[-1]) % 1000000007반응형
'Problem Solving > LeetCode' 카테고리의 다른 글
| Today's Challenge (0) | 2022.07.04 |
|---|---|
| Today's Challenge (0) | 2022.07.03 |
| Today's Challenge (0) | 2022.07.01 |
| Today's Challenge (0) | 2022.06.30 |
| Today's Challenge (0) | 2022.06.29 |
Comments