X interview question

Data strutures , Leetcode medium. Sufficient time