Pregunta de entrevista de Meta

Algorithm questions involving graphs and data. A bit tricky