Pregunta de entrevista de Intellect Design Arena

Based on Java and SQL with code given to be solved