Wisk Interview Question

complete algorithm equivalent to Leetcode hard