IBM interview question

Go do a leetcode medium and that sums it up.