Intel Corporation interview question

question from leetcode, not hard