Morgan Stanley Interview Question

Étape 1 :Coding Game Brain teaser