Bloomberg telephonic round 2022 jul

424
Jul 06, 2022
Jul 06, 2022

It was my first interview in london and I will say it went well.

for the first 10 minutes interviewer start with introduction about himself and company then ask me the same and my previous experience.
next 30-40 minutes was given to the coding part of the interview , i must say question was quite easy.

Given a positive integer n, the task is to find no of steps required to reach 1 after performing following two operations:-
If n is even, then n = n/2.
If n is odd, then n = 3*n + 1.
Repeat above steps, until it becomes 1.
ex : inp : 5
output: 5 (5->16->8->4->2->1)
follow up question :
if we get 16 as input next time can we optimise the code if we already calculated 5 because 5 inludes 16.
what i did is stored the sequene and maintain an array to store the values corresponding to that sequence.
and i got the congratulations mail from the recruiter and dates for next round as well.
hope it helps

Comments (2)