AMD Interview Question

asked a leetcode medium question