일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 10분
- 사이드
- Writing
- 뭐든
- 링피트
- 쓰릴오브파이트
- 화상영어
- 개발자
- 잡생각
- 운동
- 3줄정리
- 30분
- 영어공부
- 리얼 클래스
- 파비최
- Problem Solving
- realclass
- English
- 월간
- FIT XR
- 프로젝트
- 영어원서읽기
- 스탭퍼
Archives
- Today
- Total
파비의 매일매일 공부기록
Today's Challenge 본문
https://leetcode.com/problems/divide-two-integers/
Divide Two Integers - 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
파이썬에서는 그다지 어렵지 않은 유형 중 하나.
다만 32비트 제한에 대한 처리가 추가적으로 필요.
class Solution:
def divide(self, dividend: int, divisor: int) -> int:
res = dividend/divisor
if res >= 2**31:
return 2**31 - 1
return floor(res) if res >= 0 else ceil(res)
반응형
'Problem Solving > LeetCode' 카테고리의 다른 글
Today's Challenge (0) | 2022.06.01 |
---|---|
Today's Challenge (0) | 2022.05.31 |
Today's Challenge (0) | 2022.05.29 |
Today's Challenge (0) | 2022.05.28 |
Today's Challenge (0) | 2022.05.27 |
Comments