Intel Corporation Interview Question

question from leetcode, not hard