ZS Associates interview question

LC easy and LC medium