Pregunta de entrevista de Google

Question based on arrays, sorting n dp