IBM interview question

Leetcode Mediums and one Hard.