Rafael interview question

they gave me a leetcode problem to solve