Frage im Vorstellungsgespräch bei Microsoft

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

Antworten zu Vorstellungsgespräch

Anonym

31. Okt. 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)

Anonym

16. Jan. 2022

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

Anonym

29. Nov. 2016

Bit manipulation