Morgan Stanley interview question

Nothing very basic coding question