Facebook | Phone Screen | calculate a/b without using div and mod
Anonymous User
1406

Given non negative number a and b, output result of a/b and a%b , can't use / and %.
Example:

a = 10
b = 3
ans = "3 rem 1" ( string format)

The question is similar to https://leetcode.com/problems/divide-two-integers/


Follow-up:
What if a is a lot bigger than b, how to optimize? I heard there is a method using binary search for this case, but not sure how to apply it?

Comments (8)