Pregunta de entrevista de Valve Corporation

General algorithm questions. Implement X.