Pergunta de entrevista da empresa Acorns

Find if this array has x. We talked about optimization in this question.