Pregunta de entrevista de bp

DSA question medium difficulty. and system design.