Sahl Interview Question

Hard/medium common problem from leetcode