Question d’entretien chez Optro

I was asked to solve a data structures and algorithms problem and explain the optimized approach, complexity, and implementation details.