Goldman Sachs interview question

LC - 1 easy and 1 medium question