X

DAYS

:

HOUR

:

MINS

:

SEC

Copied to Clipboard
Division without using multiplication, division and mod operator
Medium Accuracy: 62.1% Submissions: 7583 Points: 4

Given two integers dividend and divisor. Find the quotient after dividing dividend by divisor without using multiplication, division and mod operator.

Example 1:

Input:
a = 10, b= 3
Output: 3
Exaplanation:
10/3 gives quotient as 3 
and remainder as 1.

Example 2:

Input:
a = 43, b = -8
Output: -5
Explanation:
43/-8 gives quotient as -5 and 
remainder as 3.
Your task:
You don't have to read input or print anything. Your task is to complete the function divide() which takes two integers a and b as input and returns the quotient after dividing a by b.
 
Expected Time Complexity: O(1)
Expected Auxiliary Space: O(1)
 
Constraints :
-10^9 <= a,b <= 10^9

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

Division without using multiplication, division and mod operator

Output Window