Musafir.com interview question

Leet code question on array