Goldman Sachs interview question

HackerRank coding assessment with two questions.