Pregunta de entrevista de X

Build some UI with React. Solve this algorithm question.