Tesla interview question

Very easy algorithm question and react question.