Pregunta de entrevista de Amazon

Division without divide operator

Respuestas de entrevistas

Anónimo

7 ago 2018

Just implement the long division algorithm.

Anónimo

15 ene 2019

def d(n, divisor): if divisor == 0: raise ValueError("Divisor can't be 0!"); return (n*1.0) * (divisor**-1.0)

Anónimo

7 feb 2019

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

Anónimo

22 jun 2019

int divident = 9; int divisor = 3; int quotient = 0; while(divident >= divisor) { divident -= divisor; quotient++; } System.out.println("Quotient: "+quotient+", Remainder: "+divident);

Anónimo

22 jun 2019

For the above answer, do the obvious zero checks before proceeding to the solution.