Pergunta de entrevista da empresa F5

Manager gave me a algorithm question to solve-

Resposta da entrevista

Sigiloso

7 de ago. de 2019

I solved it in iterative but in starting mentioned can be solved with recursion and got stuck for 15 mins and that was my mistake.