Pergunta de entrevista da empresa Microsoft

Write an algorithm that takes in an integer and returns the same integer but reversed

Resposta da entrevista

Sigiloso

3 de jan. de 2020

Input: num (1) Initialize rev_num = 0 (2) Loop while num > 0 (a) Multiply rev_num by 10 and add remainder of num divide by 10 to rev_num rev_num = rev_num*10 + num%10; (b) Divide num by 10 (3) Return rev_num