Loading...
Engaged Employer
Division without divide operator
Anonymous
Just implement the long division algorithm.
def d(n, divisor): if divisor == 0: raise ValueError("Divisor can't be 0!"); return (n*1.0) * (divisor**-1.0)
def parenthesisMatching(str): stack = [] for char in str: if char == '(': stack.append(char) elif char == ')': if len(stack) == 0: return False else: stack.pop() return len(stack) == 0
int divident = 9; int divisor = 3; int quotient = 0; while(divident >= divisor) { divident -= divisor; quotient++; } System.out.println("Quotient: "+quotient+", Remainder: "+divident);
For the above answer, do the obvious zero checks before proceeding to the solution.
Stay ahead in opportunities and insider tips by following your dream companies.
Get personalized job recommendations and updates by starting your searches.
Get actionable career advice tailored to you by joining more bowls.
Check out your Company Bowl for anonymous work chats.