Clear Labs Interview Question

It was a leetcode medium question.