Question d’entretien chez Uber

Multiply 2 long numbers without using multiplication.

Réponses aux questions d'entretien

Utilisateur anonyme

20 mars 2017

- (NSInteger)multiplyNum:(NSInteger)num1 with:(NSInteger)num2 { if (num2 == 0 ) return 0; if (num2 > 0) return (num1 + [self multiplyNum:num1 with:num2-1]); if (num2 < 0) return -[self multiplyNum:num1 with:-num2]; return 0; }

Utilisateur anonyme

29 sept. 2016

Bit wise operation is a possibility along with addition. I wonder if this question is more about thinking outside of the box than coming up with the most efficient alternative.

Utilisateur anonyme

9 juil. 2017

def multiply(num1,num2): results=0 results_array=[] for i in range (1,num2+1): results += num1 print(results) a=5 b=5 multiply(a,b)