Bloomberg interview question

LC problem, and some c++ basic problem