Goldman Sachs Interview Question

LC medium question, can't remember exactly