Pregunta de entrevista de SWTCH

Based on this problem, how would you solve it/ do you have any recommendations?