Pergunta de entrevista da empresa Microsoft

Given 2 integer, return their multiplication without using the multiplication operator

Respostas da entrevista

Sigiloso

31 de out. de 2017

Recursion. Manipulate only one of the two integers, let’s say y. If y is 0 then return 0. If y is greater than 0, call the same function with y-1 and return the sum of its result and x. Do not forget the case where y is negative (call the function with -y, and return the opposite)

Sigiloso

16 de jan. de 2022

function(a,b) { return (a << floor(log2(b))) + b%2==0?0:b; }

Sigiloso

29 de nov. de 2016

Bit manipulation