[LeetCode][python3]0029. Divide Two Integers

  1. My first solution
class Solution:
def divide(self, dividend: int, divisor: int) -> int:
d=False
if dividend<0:
d=not d
dividend=-dividend
if divisor<0:
divisor=-divisor
d=not d
res=dividend//divisor
if d:
res=-res
if res>2147483647:
return 2147483647
elif res<-2147483648:
return -2147483648
else:
return res

--

--

--

HI I’m N2I. Now a SWE in Taiwan. Check out more about me in https://nzi2020.blogspot.com/ or contact via email: nayzi9999@gmail.com

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Adding Effects to our player

LazyAdmin — TryHackMe — Writeup

How to Share Data Between Microservices on High Scale

60 days to become a game developer. Days 58 & 59.

Modern Data Management For Cloud Platforms

Does Automating Take Away The Human Side?

Asynchronous Methods in Dart: Async, Await, Future

Flutter & Dart

Conceptual Understanding of Ruby Classes and Objects for Beginners

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
N2I

N2I

HI I’m N2I. Now a SWE in Taiwan. Check out more about me in https://nzi2020.blogspot.com/ or contact via email: nayzi9999@gmail.com

More from Medium

Hackerrank — Insert Node in linked list walkthrough #Python #Hackerrank

Pattern 4: Merge Intervals

What is Lambda Function in python…?

Design Patterns in Python: Singleton Pattern