Optro interview question

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