Two Sigma interview question

Two intermediate level C++ programming problems.